...
1## Test keywords are identified
2
3mutable struct MutableType end
4struct ImmutableType end
5abstract type AbstractMyType end
6primitive type MyPrimitive 32 end
7(abstract, mutable, type) = true, π, missing
8
9abstract type AbstractMyType end
10primitive type MyPrimitive 32 end
11mutable struct MutableType end
12
13## Test that macros are parsed, including ones which are defined as symbols
14
15@generated function
16@. a + b
17@~ a + b
18@± a + b
19@mymacro(a, b)
20@+¹ᵀ a
21
22## Test that the range of Julia variable names are correctly identified
23
24a # single character variable
25a_simple_name
26_leading_underscore
275implicit_mul
286_more_mul
29nums1
30nums_2
31nameswith!
32multiple!!
33embedded!_inthemiddle
34embed!1
35prime_suffix′
36for_each # starts with keyword substring
37
38# variables with characters > \u00A1
39ð # category Ll
40Aʺ # category Lm -- \U02BA (MODIFIER LETTER DOUBLE PRIME), not \U2033 (DOUBLE PRIME)
41א # category Lo
42Ð # category Lu
43A̅ # category Mn -- \U0305 (COMBINING OVERLINE)
44ⅿ # category Nl -- \U217F (SMALL ROMAN NUMERAL ONE THOUSAND)
45A₁ # category No
46A² # category No
47€ # category Sc
48© # category So
49
50# number-like names
51𝟙 # category Nd
52𝟏 # category Nd
53
54## Tests identification of number forms
55
56# floats
57 1e1 1e+1 1e-1
581.1e1 1.1e+1 1.1e-1 .1e1 .1_1e1 1_1.1e1 1.1_1e1 1.1_11e1
591.1E1 1.1E+1 1.1E-1 .1E1 .1_1E1 1_1.1E1 1.1_1E1 1.1_11E1
601.1f1 1.1f+1 1.1f-1 .1f1 .1_1f1 1_1.1f1 1.1_1f1 1.1_11f1
611E1 1E+1 1E-1
621f1 1f+1 1f-1
63.1 1. 1.1 1.1_1 1.1_11 .1_1 .1_11 1_1.1_1
64# hex floats
650x1p1 0xa_bp10 0x01_ap11 0x01_abp1
660x1.1p1 0xA.Bp10 0x0.1_Ap9 0x0_1.Ap1 0x0_1.A_Bp9
67
68# integers
691 01 10_1 10_11
70
71# non-decimal
720xf 0xf_0 0xfff_000
730o7 0o7_0 0o777_000
740b1 0b1_0 0b111_000
75
76# invalid in Julia - out of range values
770xg 0o8 0b2 0x1pA
78# invalid in Julia - no trailing underscores
791_ 1.1_ 0xf_ 0o7_ 0b1_ 0xF_p1
80# parsed as juxtaposed numeral + variable in Julia (no underscores in exponents)
811e1_1 1E1_1 1f1_1 0xfp1_1
82
83# not floats -- range-like expression parts
841..1 ..1 1..
85
86## Test that operators --- dotted and unicode --- are identified correctly.
87
88a += b.c
89a .÷= .~b.c
90a = !b ⋆ c!
91a = b ? c : d ⊕ e
92a = √(5)
93a -> (a...) .+ 1
94a \ b
951..2
96a = a === b
97a <: T
98a >: T
99a::T
100[adjoint]'
101(identity)''
102adjoint'''
103transpose'ᵀ
104suffixed +¹ operator
105suffixed +¹²³ operator
106
107%% Test string forms
108
109"global function"
110"An $interpolated variable"
111"An $(a + 1) expression"
112"""a"""
113"""
114global function
115de e f
116"inner string"
117"""
118raw"\\ a \" $interp $(1 + 1) \""
119raw"""
120"inner string"
121$interp
122$(1 + 1)
123"""
124# commented "string"
125
126@sprintf "%0.2f" var
127v"1.0"
128var"#nonstandard#"
129
130r"^[abs]+$"m
131arbi"trary"suff
132arbi"trary"1234
133
134`global function`
135`abc \` \$ $interpolated`
136`abc $(a + 1)`
137```a```
138```
139global function
140"thing" ` \$
141`now` $(now())
142```
143# commented `command`
144
145arbi`trary`suff
146arbi`trary`1234
147
148## Tests that symbols are parsed as special literals
149
150:abc_123
151:abc_def
152:α
153Val{:mysymbol}
154
155# non-symbols
156a:b
1571:b
1581.:b
159a::T
160a<:T
161a>:T
162UInt(1):UInt(2)
163
164## Tests identifying names which must be types from context
165
166Union{}
167MyType{Nothing, Any}
168f(::Union{T,S}) where S where T = 1
169f(::T) where {T} = 1
170f(::Type{<:T}) = 1
171f(::AT) where AT <: AbstractArray{MyType,1} = 1
172f(::Val{:named}) = 1
173f(::typeof(sin)) = 1
174MyInt <: Integer
175Number >: MyInt
176AT{T,1} <: B
177B>:AT{T,1}
178A <: f(B)
179g(C) <: T
View as plain text