diff options
author | jmert <2965436+jmert@users.noreply.github.com> | 2021-03-05 01:31:42 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-05 08:31:42 +0100 |
commit | ffac8bde66a1060a255334ff4fb0aaf42b825eff (patch) | |
tree | 0f0b8a604346ed0437254b5dbb16ac4b3dfc4007 /tests/snippets | |
parent | ee89963c003089087d6ff7334e149a0bf99d6311 (diff) | |
download | pygments-git-ffac8bde66a1060a255334ff4fb0aaf42b825eff.tar.gz |
Update lists of operators/keywords in Julia and expand/refine highlighting (#1715)
* [julia] Update operators, keywords, and literal lists
* [julia] Support symbol macros
* [julia] Parse '..' operator juxtaposed with integers
* [julia] Identify Symbol literals
* [julia] Consume strings/commands faster & add triple-quoted command
* [julia] Support identifying operators with custom suffixes
* [julia] Add parsing for raw strings
* [julia] Share definition of interpolation
* [julia] Identify escaped ` and $ in commands
* [julia] Support non-standard string and commmand literals with flags
* [julia] Support variable names with interior exclamations
* [julia] Fix matching floats starting with decimal
* [julia] Compress nearly duplicate number matches with optional group
* [julia] Match double-underscored float literal
* [julia] Match hex float literals
* [julia] Test more non-numerical literal expressions
* [julia] Tag types in type contexts
* [julia] Identify console via `julia-repl` as well
* [julia] Be more conservative in identifying symbols
* [julia] Update example file to v1.6 `base/strings/string.jl`
* Address one CI failure
* Switch to non-emoji Unicode category So example
Hopefully fixes pypy3 CI failure
* fixup: remove duplicate operators already in DOTTED_OPERATORS_LIST
* [julia] Fix backslash operator
* [julia] List `true`, `false` with builtin names, not keywords
Diffstat (limited to 'tests/snippets')
-rw-r--r-- | tests/snippets/julia-repl/test_repl.txt | 51 | ||||
-rw-r--r-- | tests/snippets/julia/test_keywords.txt | 89 | ||||
-rw-r--r-- | tests/snippets/julia/test_macros.txt | 56 | ||||
-rw-r--r-- | tests/snippets/julia/test_names.txt | 148 | ||||
-rw-r--r-- | tests/snippets/julia/test_numbers.txt | 261 | ||||
-rw-r--r-- | tests/snippets/julia/test_operators.txt | 172 | ||||
-rw-r--r-- | tests/snippets/julia/test_strings.txt | 225 | ||||
-rw-r--r-- | tests/snippets/julia/test_symbols.txt | 78 | ||||
-rw-r--r-- | tests/snippets/julia/test_types.txt | 196 |
9 files changed, 1276 insertions, 0 deletions
diff --git a/tests/snippets/julia-repl/test_repl.txt b/tests/snippets/julia-repl/test_repl.txt new file mode 100644 index 00000000..798f0047 --- /dev/null +++ b/tests/snippets/julia-repl/test_repl.txt @@ -0,0 +1,51 @@ +Tests separating Julia's commands from output in REPL-like code blocks + +---input--- +julia> f(x) = sin(π/2x) +f (generic function with 1 method) + +julia> @. f(1:2) +2-element Vector{Float64}: + 1.0 + 0.7071067811865475 + +---tokens--- +'julia>' Generic.Prompt +' ' Text +'f' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'sin' Name +'(' Punctuation +'π' Name.Builtin +'/' Operator +'2' Literal.Number.Integer +'x' Name +')' Punctuation +'\n' Text + +'f (generic function with 1 method)\n' Generic.Output + +'\n' Generic.Output + +'julia>' Generic.Prompt +' ' Text +'@.' Name.Decorator +' ' Text +'f' Name +'(' Punctuation +'1' Literal.Number.Integer +':' Operator +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'2-element Vector{Float64}:\n' Generic.Output + +' 1.0\n' Generic.Output + +' 0.7071067811865475\n' Generic.Output diff --git a/tests/snippets/julia/test_keywords.txt b/tests/snippets/julia/test_keywords.txt new file mode 100644 index 00000000..235c411c --- /dev/null +++ b/tests/snippets/julia/test_keywords.txt @@ -0,0 +1,89 @@ +# Test keywords are identified + +---input--- +mutable struct MutableType end +struct ImmutableType end +abstract type AbstractMyType end +primitive type MyPrimitive 32 end +(abstract, mutable, type) = true, π, missing + +abstract type AbstractMyType end +primitive type MyPrimitive 32 end +mutable struct MutableType end + +---tokens--- +'mutable struct' Keyword +' ' Text +'MutableType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'struct' Keyword +' ' Text +'ImmutableType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'abstract type' Keyword +' ' Text +'AbstractMyType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'primitive type' Keyword +' ' Text +'MyPrimitive' Keyword.Type +' ' Text +'32' Literal.Number.Integer +' ' Text +'end' Keyword +'\n' Text + +'(' Punctuation +'abstract' Name +',' Punctuation +' ' Text +'mutable' Name +',' Punctuation +' ' Text +'type' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'true' Name.Builtin +',' Punctuation +' ' Text +'π' Name.Builtin +',' Punctuation +' ' Text +'missing' Name.Builtin +'\n' Text + +'\n' Text + +'abstract type' Keyword +' ' Text +'AbstractMyType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'primitive \ttype' Keyword +' ' Text +'MyPrimitive' Keyword.Type +' ' Text +'32' Literal.Number.Integer +' ' Text +'end' Keyword +'\n' Text + +'mutable struct' Keyword +' ' Text +'MutableType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text diff --git a/tests/snippets/julia/test_macros.txt b/tests/snippets/julia/test_macros.txt new file mode 100644 index 00000000..8dc27187 --- /dev/null +++ b/tests/snippets/julia/test_macros.txt @@ -0,0 +1,56 @@ +# Test that macros are parsed, including ones which are defined as symbols + +---input--- +@generated function +@. a + b +@~ a + b +@± a + b +@mymacro(a, b) +@+¹ᵀ a + +---tokens--- +'@generated' Name.Decorator +' ' Text +'function' Keyword +'\n' Text + +'@.' Name.Decorator +' ' Text +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n' Text + +'@~' Name.Decorator +' ' Text +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n' Text + +'@±' Name.Decorator +' ' Text +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n' Text + +'@mymacro' Name.Decorator +'(' Punctuation +'a' Name +',' Punctuation +' ' Text +'b' Name +')' Punctuation +'\n' Text + +'@+¹ᵀ' Name.Decorator +' ' Text +'a' Name +'\n' Text diff --git a/tests/snippets/julia/test_names.txt b/tests/snippets/julia/test_names.txt new file mode 100644 index 00000000..338f483f --- /dev/null +++ b/tests/snippets/julia/test_names.txt @@ -0,0 +1,148 @@ +# Test that the range of Julia variable names are correctly identified + +---input--- +a # single character variable +a_simple_name +_leading_underscore +5implicit_mul +6_more_mul +nums1 +nums_2 +nameswith! +multiple!! +embedded!_inthemiddle +embed!1 +prime_suffix′ +for_each # starts with keyword substring + +# variables with characters > \u00A1 +ð # category Ll +Aʺ # category Lm -- \U02BA (MODIFIER LETTER DOUBLE PRIME), not \U2033 (DOUBLE PRIME) +א # category Lo +Ð # category Lu +A̅ # category Mn -- \U0305 (COMBINING OVERLINE) +ⅿ # category Nl -- \U217F (SMALL ROMAN NUMERAL ONE THOUSAND) +A₁ # category No +A² # category No +€ # category Sc +© # category So + +# number-like names +𝟙 # category Nd +𝟏 # category Nd + +---tokens--- +'a' Name +' ' Text +'# single character variable' Comment +'\n' Text + +'a_simple_name' Name +'\n' Text + +'_leading_underscore' Name +'\n' Text + +'5' Literal.Number.Integer +'implicit_mul' Name +'\n' Text + +'6' Literal.Number.Integer +'_more_mul' Name +'\n' Text + +'nums1' Name +'\n' Text + +'nums_2' Name +'\n' Text + +'nameswith!' Name +'\n' Text + +'multiple!!' Name +'\n' Text + +'embedded!_inthemiddle' Name +'\n' Text + +'embed!1' Name +'\n' Text + +'prime_suffix′' Name +'\n' Text + +'for_each' Name +' ' Text +'# starts with keyword substring' Comment +'\n' Text + +'\n' Text + +'# variables with characters > \\u00A1' Comment +'\n' Text + +'ð' Name +' ' Text +'# category Ll' Comment +'\n' Text + +'Aʺ' Name +' ' Text +'# category Lm -- \\U02BA (MODIFIER LETTER DOUBLE PRIME), not \\U2033 (DOUBLE PRIME)' Comment +'\n' Text + +'א' Name +' ' Text +'# category Lo' Comment +'\n' Text + +'Ð' Name +' ' Text +'# category Lu' Comment +'\n' Text + +'A̅' Name +' ' Text +'# category Mn -- \\U0305 (COMBINING OVERLINE)' Comment +'\n' Text + +'ⅿ' Name +' ' Text +'# category Nl -- \\U217F (SMALL ROMAN NUMERAL ONE THOUSAND)' Comment +'\n' Text + +'A₁' Name +' ' Text +'# category No' Comment +'\n' Text + +'A²' Name +' ' Text +'# category No' Comment +'\n' Text + +'€' Name +' ' Text +'# category Sc' Comment +'\n' Text + +'©' Name +' ' Text +'# category So' Comment +'\n' Text + +'\n' Text + +'# number-like names' Comment +'\n' Text + +'𝟙' Name +' ' Text +'# category Nd' Comment +'\n' Text + +'𝟏' Name +' ' Text +'# category Nd' Comment +'\n' Text diff --git a/tests/snippets/julia/test_numbers.txt b/tests/snippets/julia/test_numbers.txt new file mode 100644 index 00000000..5c572438 --- /dev/null +++ b/tests/snippets/julia/test_numbers.txt @@ -0,0 +1,261 @@ +# Tests identification of number forms + +---input--- +# floats + 1e1 1e+1 1e-1 +1.1e1 1.1e+1 1.1e-1 .1e1 .1_1e1 1_1.1e1 1.1_1e1 1.1_11e1 +1.1E1 1.1E+1 1.1E-1 .1E1 .1_1E1 1_1.1E1 1.1_1E1 1.1_11E1 +1.1f1 1.1f+1 1.1f-1 .1f1 .1_1f1 1_1.1f1 1.1_1f1 1.1_11f1 +1E1 1E+1 1E-1 +1f1 1f+1 1f-1 +.1 1. 1.1 1.1_1 1.1_11 .1_1 .1_11 1_1.1_1 +# hex floats +0x1p1 0xa_bp10 0x01_ap11 0x01_abp1 +0x1.1p1 0xA.Bp10 0x0.1_Ap9 0x0_1.Ap1 0x0_1.A_Bp9 + +# integers +1 01 10_1 10_11 + +# non-decimal +0xf 0xf_0 0xfff_000 +0o7 0o7_0 0o777_000 +0b1 0b1_0 0b111_000 + +# invalid in Julia - out of range values +0xg 0o8 0b2 0x1pA +# invalid in Julia - no trailing underscores +1_ 1.1_ 0xf_ 0o7_ 0b1_ 0xF_p1 +# parsed as juxtaposed numeral + variable in Julia (no underscores in exponents) +1e1_1 1E1_1 1f1_1 0xfp1_1 + +# not floats -- range-like expression parts +1..1 ..1 1.. + +---tokens--- +'# floats' Comment +'\n' Text + +' ' Text +'1e1' Literal.Number.Float +' ' Text +'1e+1' Literal.Number.Float +' ' Text +'1e-1' Literal.Number.Float +'\n' Text + +'1.1e1' Literal.Number.Float +' ' Text +'1.1e+1' Literal.Number.Float +' ' Text +'1.1e-1' Literal.Number.Float +' ' Text +'.1e1' Literal.Number.Float +' ' Text +'.1_1e1' Literal.Number.Float +' ' Text +'1_1.1e1' Literal.Number.Float +' ' Text +'1.1_1e1' Literal.Number.Float +' ' Text +'1.1_11e1' Literal.Number.Float +'\n' Text + +'1.1E1' Literal.Number.Float +' ' Text +'1.1E+1' Literal.Number.Float +' ' Text +'1.1E-1' Literal.Number.Float +' ' Text +'.1E1' Literal.Number.Float +' ' Text +'.1_1E1' Literal.Number.Float +' ' Text +'1_1.1E1' Literal.Number.Float +' ' Text +'1.1_1E1' Literal.Number.Float +' ' Text +'1.1_11E1' Literal.Number.Float +'\n' Text + +'1.1f1' Literal.Number.Float +' ' Text +'1.1f+1' Literal.Number.Float +' ' Text +'1.1f-1' Literal.Number.Float +' ' Text +'.1f1' Literal.Number.Float +' ' Text +'.1_1f1' Literal.Number.Float +' ' Text +'1_1.1f1' Literal.Number.Float +' ' Text +'1.1_1f1' Literal.Number.Float +' ' Text +'1.1_11f1' Literal.Number.Float +'\n' Text + +'1E1' Literal.Number.Float +' ' Text +'1E+1' Literal.Number.Float +' ' Text +'1E-1' Literal.Number.Float +'\n' Text + +'1f1' Literal.Number.Float +' ' Text +'1f+1' Literal.Number.Float +' ' Text +'1f-1' Literal.Number.Float +'\n' Text + +'.1' Literal.Number.Float +' ' Text +'1.' Literal.Number.Float +' ' Text +'1.1' Literal.Number.Float +' ' Text +'1.1_1' Literal.Number.Float +' ' Text +'1.1_11' Literal.Number.Float +' ' Text +'.1_1' Literal.Number.Float +' ' Text +'.1_11' Literal.Number.Float +' ' Text +'1_1.1_1' Literal.Number.Float +'\n' Text + +'# hex floats' Comment +'\n' Text + +'0x1p1' Literal.Number.Float +' ' Text +'0xa_bp10' Literal.Number.Float +' ' Text +'0x01_ap11' Literal.Number.Float +' ' Text +'0x01_abp1' Literal.Number.Float +'\n' Text + +'0x1.1p1' Literal.Number.Float +' ' Text +'0xA.Bp10' Literal.Number.Float +' ' Text +'0x0.1_Ap9' Literal.Number.Float +' ' Text +'0x0_1.Ap1' Literal.Number.Float +' ' Text +'0x0_1.A_Bp9' Literal.Number.Float +'\n' Text + +'\n' Text + +'# integers' Comment +'\n' Text + +'1' Literal.Number.Integer +' ' Text +'01' Literal.Number.Integer +' ' Text +'10_1' Literal.Number.Integer +' ' Text +'10_11' Literal.Number.Integer +'\n' Text + +'\n' Text + +'# non-decimal' Comment +'\n' Text + +'0xf' Literal.Number.Hex +' ' Text +'0xf_0' Literal.Number.Hex +' ' Text +'0xfff_000' Literal.Number.Hex +'\n' Text + +'0o7' Literal.Number.Oct +' ' Text +'0o7_0' Literal.Number.Oct +' ' Text +'0o777_000' Literal.Number.Oct +'\n' Text + +'0b1' Literal.Number.Bin +' ' Text +'0b1_0' Literal.Number.Bin +' ' Text +'0b111_000' Literal.Number.Bin +'\n' Text + +'\n' Text + +'# invalid in Julia - out of range values' Comment +'\n' Text + +'0' Literal.Number.Integer +'xg' Name +' ' Text +'0' Literal.Number.Integer +'o8' Name +' ' Text +'0' Literal.Number.Integer +'b2' Name +' ' Text +'0x1' Literal.Number.Hex +'pA' Name +'\n' Text + +'# invalid in Julia - no trailing underscores' Comment +'\n' Text + +'1' Literal.Number.Integer +'_' Name +' ' Text +'1.1' Literal.Number.Float +'_' Name +' ' Text +'0xf' Literal.Number.Hex +'_' Name +' ' Text +'0o7' Literal.Number.Oct +'_' Name +' ' Text +'0b1' Literal.Number.Bin +'_' Name +' ' Text +'0xF' Literal.Number.Hex +'_p1' Name +'\n' Text + +'# parsed as juxtaposed numeral + variable in Julia (no underscores in exponents)' Comment +'\n' Text + +'1e1' Literal.Number.Float +'_1' Name +' ' Text +'1E1' Literal.Number.Float +'_1' Name +' ' Text +'1f1' Literal.Number.Float +'_1' Name +' ' Text +'0xfp1' Literal.Number.Float +'_1' Name +'\n' Text + +'\n' Text + +'# not floats -- range-like expression parts' Comment +'\n' Text + +'1' Literal.Number.Integer +'..' Operator +'1' Literal.Number.Integer +' ' Text +'..' Operator +'1' Literal.Number.Integer +' ' Text +'1' Literal.Number.Integer +'..' Operator +'\n' Text diff --git a/tests/snippets/julia/test_operators.txt b/tests/snippets/julia/test_operators.txt new file mode 100644 index 00000000..017a48e9 --- /dev/null +++ b/tests/snippets/julia/test_operators.txt @@ -0,0 +1,172 @@ +# Test that operators --- dotted and unicode --- are identified correctly. + +---input--- +a += b.c +a .÷= .~b.c +a = !b ⋆ c! +a = b ? c : d ⊕ e +a = √(5) +a -> (a...) .+ 1 +a \ b +1..2 +a = a === b +a <: T +a >: T +a::T +[adjoint]' +(identity)'' +adjoint''' +transpose'ᵀ +suffixed +¹ operator +suffixed +¹²³ operator + +---tokens--- +'a' Name +' ' Text +'+=' Operator +' ' Text +'b' Name +'.' Operator +'c' Name +'\n' Text + +'a' Name +' ' Text +'.÷=' Operator +' ' Text +'.~' Operator +'b' Name +'.' Operator +'c' Name +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'!' Operator +'b' Name +' ' Text +'⋆' Operator +' ' Text +'c!' Name +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'b' Name +' ' Text +'?' Operator +' ' Text +'c' Name +' ' Text +':' Operator +' ' Text +'d' Name +' ' Text +'⊕' Operator +' ' Text +'e' Name +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'√' Operator +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'\n' Text + +'a' Name +' ' Text +'->' Operator +' ' Text +'(' Punctuation +'a' Name +'...' Operator +')' Punctuation +' ' Text +'.+' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'a' Name +' ' Text +'\\' Operator +' ' Text +'b' Name +'\n' Text + +'1' Literal.Number.Integer +'..' Operator +'2' Literal.Number.Integer +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'===' Operator +' ' Text +'b' Name +'\n' Text + +'a' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'T' Keyword.Type +'\n' Text + +'a' Keyword.Type +' ' Text +'>:' Operator +' ' Text +'T' Keyword.Type +'\n' Text + +'a' Name +'::' Operator +'T' Keyword.Type +'\n' Text + +'[' Punctuation +'adjoint' Name +']' Punctuation +"'" Operator +'\n' Text + +'(' Punctuation +'identity' Name +')' Punctuation +"''" Operator +'\n' Text + +'adjoint' Name +"'''" Operator +'\n' Text + +'transpose' Name +"'ᵀ" Operator +'\n' Text + +'suffixed' Name +' ' Text +'+¹' Operator +' ' Text +'operator' Name +'\n' Text + +'suffixed' Name +' ' Text +'+¹²³' Operator +' ' Text +'operator' Name +'\n' Text diff --git a/tests/snippets/julia/test_strings.txt b/tests/snippets/julia/test_strings.txt new file mode 100644 index 00000000..436bfe3c --- /dev/null +++ b/tests/snippets/julia/test_strings.txt @@ -0,0 +1,225 @@ +# Tests string forms + +---input--- +"global function" +"An $interpolated variable" +"An $(a + 1) expression" +"""a""" +""" +global function +de e f +"inner string" +""" +raw"\\ a \" $interp $(1 + 1) \"" +raw""" +"inner string" +$interp +$(1 + 1) +""" +# commented "string" + +@sprintf "%0.2f" var +v"1.0" +var"#nonstandard#" + +r"^[abs]+$"m +arbi"trary"suff +arbi"trary"1234 + +`global function` +`abc \` \$ $interpolated` +`abc $(a + 1)` +```a``` +``` +global function +"thing" ` \$ +`now` $(now()) +``` +# commented `command` + +arbi`trary`suff +arbi`trary`1234 + +---tokens--- +'"' Literal.String +'global function' Literal.String +'"' Literal.String +'\n' Text + +'"' Literal.String +'An ' Literal.String +'$interpolated' Literal.String.Interpol +' variable' Literal.String +'"' Literal.String +'\n' Text + +'"' Literal.String +'An ' Literal.String +'$' Literal.String.Interpol +'(' Punctuation +'a' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +' expression' Literal.String +'"' Literal.String +'\n' Text + +'"""' Literal.String +'a' Literal.String +'"""' Literal.String +'\n' Text + +'"""' Literal.String +'\nglobal function\nde e f\n' Literal.String + +'"' Literal.String +'inner string' Literal.String +'"' Literal.String +'\n' Literal.String + +'"""' Literal.String +'\n' Text + +'raw' Literal.String.Affix +'"' Literal.String +'\\\\ a ' Literal.String +'\\"' Literal.String.Escape +' $interp $(1 + 1) ' Literal.String +'\\"' Literal.String.Escape +'"' Literal.String +'\n' Text + +'raw' Literal.String.Affix +'"""' Literal.String +'\n"inner string"\n$interp\n$(1 + 1)\n' Literal.String + +'"""' Literal.String +'\n' Text + +'# commented "string"' Comment +'\n' Text + +'\n' Text + +'@sprintf' Name.Decorator +' ' Text +'"' Literal.String +'%0.2f' Literal.String.Interpol +'"' Literal.String +' ' Text +'var' Name +'\n' Text + +'v' Literal.String.Affix +'"' Literal.String +'1.0' Literal.String +'"' Literal.String +'\n' Text + +'var' Literal.String.Affix +'"' Literal.String +'#nonstandard#' Literal.String +'"' Literal.String +'\n' Text + +'\n' Text + +'r' Literal.String.Affix +'"' Literal.String.Regex +'^[abs]+$' Literal.String.Regex +'"' Literal.String.Regex +'m' Literal.String.Affix +'\n' Text + +'arbi' Literal.String.Affix +'"' Literal.String +'trary' Literal.String +'"' Literal.String +'suff' Literal.String.Affix +'\n' Text + +'arbi' Literal.String.Affix +'"' Literal.String +'trary' Literal.String +'"' Literal.String +'1234' Literal.String.Affix +'\n' Text + +'\n' Text + +'`' Literal.String.Backtick +'global function' Literal.String.Backtick +'`' Literal.String.Backtick +'\n' Text + +'`' Literal.String.Backtick +'abc ' Literal.String.Backtick +'\\`' Literal.String.Escape +' ' Literal.String.Backtick +'\\$' Literal.String.Escape +' ' Literal.String.Backtick +'$interpolated' Literal.String.Interpol +'`' Literal.String.Backtick +'\n' Text + +'`' Literal.String.Backtick +'abc ' Literal.String.Backtick +'$' Literal.String.Interpol +'(' Punctuation +'a' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +'`' Literal.String.Backtick +'\n' Text + +'```' Literal.String.Backtick +'a' Literal.String.Backtick +'```' Literal.String.Backtick +'\n' Text + +'```' Literal.String.Backtick +'\nglobal function\n"thing" ' Literal.String.Backtick +'`' Literal.String.Backtick +' ' Literal.String.Backtick +'\\$' Literal.String.Escape +'\n' Literal.String.Backtick + +'`' Literal.String.Backtick +'now' Literal.String.Backtick +'`' Literal.String.Backtick +' ' Literal.String.Backtick +'$' Literal.String.Interpol +'(' Punctuation +'now' Name +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Literal.String.Backtick + +'```' Literal.String.Backtick +'\n' Text + +'# commented `command`' Comment +'\n' Text + +'\n' Text + +'arbi' Literal.String.Affix +'`' Literal.String.Backtick +'trary' Literal.String.Backtick +'`' Literal.String.Backtick +'suff' Literal.String.Affix +'\n' Text + +'arbi' Literal.String.Affix +'`' Literal.String.Backtick +'trary' Literal.String.Backtick +'`' Literal.String.Backtick +'1234' Literal.String.Affix +'\n' Text diff --git a/tests/snippets/julia/test_symbols.txt b/tests/snippets/julia/test_symbols.txt new file mode 100644 index 00000000..8b85a8e1 --- /dev/null +++ b/tests/snippets/julia/test_symbols.txt @@ -0,0 +1,78 @@ +# Tests that symbols are parsed as special literals + +---input--- +:abc_123 +:abc_def +:α +Val{:mysymbol} + +# non-symbols +a:b +1:b +1.:b +a::T +a<:T +a>:T +UInt(1):UInt(2) + +---tokens--- +':abc_123' Literal.String.Symbol +'\n' Text + +':abc_def' Literal.String.Symbol +'\n' Text + +':α' Literal.String.Symbol +'\n' Text + +'Val' Keyword.Type +'{' Punctuation +':mysymbol' Literal.String.Symbol +'}' Punctuation +'\n' Text + +'\n' Text + +'# non-symbols' Comment +'\n' Text + +'a' Name +':' Operator +'b' Name +'\n' Text + +'1' Literal.Number.Integer +':' Operator +'b' Name +'\n' Text + +'1.' Literal.Number.Float +':' Operator +'b' Name +'\n' Text + +'a' Name +'::' Operator +'T' Keyword.Type +'\n' Text + +'a' Keyword.Type +'<:' Operator +'T' Keyword.Type +'\n' Text + +'a' Keyword.Type +'>:' Operator +'T' Keyword.Type +'\n' Text + +'UInt' Keyword.Type +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +':' Operator +'UInt' Keyword.Type +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n' Text diff --git a/tests/snippets/julia/test_types.txt b/tests/snippets/julia/test_types.txt new file mode 100644 index 00000000..dc475349 --- /dev/null +++ b/tests/snippets/julia/test_types.txt @@ -0,0 +1,196 @@ +# Tests identifying names which must be types from context + +---input--- +Union{} +MyType{Nothing, Any} +f(::Union{T,S}) where S where T = 1 +f(::T) where {T} = 1 +f(::Type{<:T}) = 1 +f(::AT) where AT <: AbstractArray{MyType,1} = 1 +f(::Val{:named}) = 1 +f(::typeof(sin)) = 1 +MyInt <: Integer +Number >: MyInt +AT{T,1} <: B +B>:AT{T,1} +A <: f(B) +g(C) <: T + +---tokens--- +'Union' Keyword.Type +'{' Punctuation +'}' Punctuation +'\n' Text + +'MyType' Keyword.Type +'{' Punctuation +'Nothing' Keyword.Type +',' Punctuation +' ' Text +'Any' Keyword.Type +'}' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'Union' Keyword.Type +'{' Punctuation +'T' Keyword.Type +',' Punctuation +'S' Keyword.Type +'}' Punctuation +')' Punctuation +' ' Text +'where' Keyword +' ' Text +'S' Keyword.Type +' ' Text +'where' Keyword +' ' Text +'T' Keyword.Type +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'T' Keyword.Type +')' Punctuation +' ' Text +'where' Keyword +' ' Text +'{' Punctuation +'T' Keyword.Type +'}' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'Type' Keyword.Type +'{' Punctuation +'<:' Operator +'T' Keyword.Type +'}' Punctuation +')' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'AT' Keyword.Type +')' Punctuation +' ' Text +'where' Keyword +' ' Text +'AT' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'AbstractArray' Keyword.Type +'{' Punctuation +'MyType' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +'}' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'Val' Keyword.Type +'{' Punctuation +':named' Literal.String.Symbol +'}' Punctuation +')' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'typeof' Name +'(' Punctuation +'sin' Name +')' Punctuation +')' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'MyInt' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'Integer' Keyword.Type +'\n' Text + +'Number' Keyword.Type +' ' Text +'>:' Operator +' ' Text +'MyInt' Keyword.Type +'\n' Text + +'AT' Keyword.Type +'{' Punctuation +'T' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +'}' Punctuation +' ' Text +'<:' Operator +' ' Text +'B' Keyword.Type +'\n' Text + +'B' Keyword.Type +'>:' Operator +'AT' Keyword.Type +'{' Punctuation +'T' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +'}' Punctuation +'\n' Text + +'A' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'f' Name +'(' Punctuation +'B' Name +')' Punctuation +'\n' Text + +'g' Name +'(' Punctuation +'C' Name +')' Punctuation +' ' Text +'<:' Operator +' ' Text +'T' Keyword.Type +'\n' Text |