Changeset View
Changeset View
Standalone View
Standalone View
autotests/input/highlight.lua
- This file was added.
1 | #!/usr/bin/env lua | ||||
---|---|---|---|---|---|
2 | | ||||
3 | -- Metatables | ||||
4 | t = { | ||||
5 | __add=function(a,b)return a+b end, | ||||
6 | __sub=function(a,b)return a-b end, | ||||
7 | __mul=function(a,b)return a*b end, | ||||
8 | __div=function(a,b)return a/b end, | ||||
9 | __mod=function(a,b)return a%b end, | ||||
10 | __pow=function(a,b)return a^b end, | ||||
11 | __unm=function(a)return -a end, | ||||
12 | __idiv=function(a,b)return a//b end, | ||||
13 | __band=function(a,b)return a&b end, | ||||
14 | __bor=function(a,b)return a|b end, | ||||
15 | __bxor=function(a,b)return a~b end, | ||||
16 | __bnot=function(a)return ~a end, | ||||
17 | __shl=function(a,b)return a<<b end, | ||||
18 | __shr=function(a,b)return a>>b end, | ||||
19 | __concat=function(a,b)return a..b end, | ||||
20 | __len=function(a)return #a end, | ||||
21 | __eq=function(a,b)return a==b end, | ||||
22 | __lt=function(a,b)return a<b end, | ||||
23 | __le=function(a,b)return a<=b end, | ||||
24 | __index=function(t,k)return t[k] end, | ||||
25 | __newindex=function(t,k,v)return t[k]=v end, | ||||
26 | __call=function(f, ...)return f(...) end, | ||||
27 | | ||||
28 | __tostring=function(a)return tostring(a) end, | ||||
29 | __pairs=function(t)return pairs(a) end, | ||||
30 | -- setmetatable | ||||
31 | __metatable=true | ||||
32 | -- Garbage collector | ||||
33 | __gc=function() end | ||||
34 | -- Weak table | ||||
35 | __mode='k' -- or 'v' | ||||
36 | } | ||||
37 | | ||||
38 | a or b | ||||
39 | a and b | ||||
40 | a~=b | ||||
41 | a>=b | ||||
42 | true or false | ||||
43 | a or nil | ||||
44 | a::m | ||||
45 | a.m | ||||
46 | a;a | ||||
47 | | ||||
48 | | ||||
49 | -- String | ||||
50 | '\a' | ||||
51 | '\b' | ||||
52 | '\f' | ||||
53 | '\n' | ||||
54 | '\r' | ||||
55 | '\t' | ||||
56 | '\v' | ||||
57 | '\\' | ||||
58 | '\"' | ||||
59 | '\'' | ||||
60 | '\z' | ||||
61 | '\xff' | ||||
62 | '\xFF' | ||||
63 | '\231' | ||||
64 | '\23' | ||||
65 | '\2' | ||||
66 | '\u{100201}' -- max 6 digits | ||||
67 | '\2a\ks' -- error | ||||
68 | | ||||
69 | a = 'alo\n123"' | ||||
70 | a = "alo\n123\"" | ||||
71 | a = '\97lo\10\04923"' | ||||
72 | a = [[alo | ||||
73 | 123"]] | ||||
74 | a = [==[ | ||||
75 | alo | ||||
76 | 123"]==] | ||||
77 | | ||||
78 | | ||||
79 | -- Decimal | ||||
80 | 3 | ||||
81 | 345 | ||||
82 | 0xff | ||||
83 | 0xBEBADA | ||||
84 | | ||||
85 | -- Float | ||||
86 | 3. | ||||
87 | .3 | ||||
88 | 3.0 | ||||
89 | 3.1416 | ||||
90 | 314.16e-2 | ||||
91 | 314.e+2 | ||||
92 | 0.31416E1 | ||||
93 | 34e1 | ||||
94 | 0.e3 | ||||
95 | 0x0.1E | ||||
96 | 0xA23p-4 | ||||
97 | 0xA.p+4 | ||||
98 | 0x.ap4 | ||||
99 | 0X1.921FB54442D18P+1 | ||||
100 | -- error | ||||
101 | 32p | ||||
102 | 0xp-4 | ||||
103 | 0x.p-4 | ||||
104 | | ||||
105 | | ||||
106 | -- single comment | ||||
107 | xyz() | ||||
108 | --[[ | ||||
109 | long comment | ||||
110 | ]] | ||||
111 | xyz() | ||||
112 | | ||||
113 | | ||||
114 | a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 } | ||||
115 | | ||||
116 | -- is equivalent to | ||||
117 | | ||||
118 | do | ||||
119 | local t = {} | ||||
120 | t[f(1)] = g | ||||
121 | t[1] = "x" -- 1st exp | ||||
122 | t[2] = "y" -- 2nd exp | ||||
123 | t.x = 1 -- t["x"] = 1 | ||||
124 | t[3] = f(x) -- 3rd exp | ||||
125 | t[30] = 23 | ||||
126 | t[4] = 45 -- 4th exp | ||||
127 | a = t | ||||
128 | end | ||||
129 | | ||||
130 | 32-0x43+0x2-5 | ||||
131 | return"a" | ||||
132 | return'a' | ||||
133 | return{} | ||||
134 | f(3) | ||||
135 | f'a' | ||||
136 | f"a" | ||||
137 | f{s=2} | ||||
138 | f[[s]] | ||||
139 | f[=[s]=] | ||||
140 | #a | ||||
141 | | ||||
142 | local CONSTANT = a | ||||
143 | | ||||
144 | a = {} | ||||
145 | local x = 20 | ||||
146 | for i=1,10 do | ||||
147 | local y = 0 | ||||
148 | a[i] = function () y=y+1; return x+y end | ||||
149 | end | ||||
150 | | ||||
151 | --! \brief gfind is deprecated | ||||
152 | string.gfind('s') | ||||
153 | string.gmatch('f') |