| 1 |
/* |
| 2 |
Copyright 2015 Google Inc. All rights reserved. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
|
| 18 |
{ |
| 19 |
local test_local = { |
| 20 |
f: 1, |
| 21 |
}, |
| 22 |
|
| 23 |
local test_local2 = |
| 24 |
{ |
| 25 |
g: 2, |
| 26 |
}, |
| 27 |
|
| 28 |
local test_local3(x, |
| 29 |
y) = |
| 30 |
{ |
| 31 |
g: 2, |
| 32 |
}, |
| 33 |
|
| 34 |
local test_local4( |
| 35 |
x, y |
| 36 |
) = { |
| 37 |
g: 2, |
| 38 |
}, |
| 39 |
|
| 40 |
local test_local5 = { |
| 41 |
x: |
| 42 |
true, |
| 43 |
}, |
| 44 |
|
| 45 |
local test_local_default1(x=100, y=200) = { |
| 46 |
g: 2, |
| 47 |
}, |
| 48 |
|
| 49 |
local test_local_default2( |
| 50 |
x=100, |
| 51 |
y=200 |
| 52 |
) |
| 53 |
= { |
| 54 |
g: 2, |
| 55 |
}, |
| 56 |
|
| 57 |
local f(a, b) = null, |
| 58 |
func: /*0*/ f/*1*/(/*2*/ 'x'/*3*/, /*4*/ 'y'/*5*/,/*6*/)/*7*/, |
| 59 |
|
| 60 |
test_field0A: { |
| 61 |
g: 1, |
| 62 |
}, |
| 63 |
|
| 64 |
test_field1A: |
| 65 |
{ |
| 66 |
g: 1, |
| 67 |
}, |
| 68 |
|
| 69 |
test_field0B: { |
| 70 |
f: 1, |
| 71 |
g: 1, |
| 72 |
}, |
| 73 |
|
| 74 |
test_field1B: |
| 75 |
{ |
| 76 |
f: 1, |
| 77 |
g: 1, |
| 78 |
}, |
| 79 |
|
| 80 |
test_field2: if true then |
| 81 |
100 |
| 82 |
else |
| 83 |
200, |
| 84 |
|
| 85 |
test_field2b: if true |
| 86 |
&& true |
| 87 |
then |
| 88 |
100 |
| 89 |
else |
| 90 |
200, |
| 91 |
|
| 92 |
test_field2c: if |
| 93 |
true |
| 94 |
then |
| 95 |
100 |
| 96 |
else |
| 97 |
200, |
| 98 |
|
| 99 |
test_field2d: if true |
| 100 |
then 100 |
| 101 |
else 200, |
| 102 |
|
| 103 |
test_field3: |
| 104 |
if true then |
| 105 |
100 |
| 106 |
else |
| 107 |
200, |
| 108 |
|
| 109 |
test_field4: 1000 |
| 110 |
+ 2000, |
| 111 |
|
| 112 |
test_field4b: 1000 + |
| 113 |
2000, |
| 114 |
|
| 115 |
test_field4c: 1000 + 2000 + 3000 |
| 116 |
+ 4000 + 5000, |
| 117 |
|
| 118 |
test_field5: |
| 119 |
1000 |
| 120 |
+ 2000, |
| 121 |
|
| 122 |
local A = {}, |
| 123 |
|
| 124 |
test_field6: A { |
| 125 |
g: 1, |
| 126 |
}, |
| 127 |
|
| 128 |
test_field7: A |
| 129 |
{ |
| 130 |
f: 3, |
| 131 |
}, |
| 132 |
|
| 133 |
test_field7f: f |
| 134 |
( |
| 135 |
1, |
| 136 |
2, |
| 137 |
), |
| 138 |
|
| 139 |
test_field7f2: /* hello */ f |
| 140 |
(1, |
| 141 |
2) |
| 142 |
tailstrict, |
| 143 |
|
| 144 |
local g(a) = null, |
| 145 |
test_field8: g({ |
| 146 |
f: 3, |
| 147 |
}), |
| 148 |
|
| 149 |
test_field8b: f(10, { |
| 150 |
f: 3, |
| 151 |
}), |
| 152 |
|
| 153 |
test_field9a: g( |
| 154 |
{ |
| 155 |
f: 3, |
| 156 |
} |
| 157 |
), |
| 158 |
|
| 159 |
test_field9b: g( |
| 160 |
{ |
| 161 |
f: 3, |
| 162 |
} |
| 163 |
), |
| 164 |
|
| 165 |
test_field9c: f(10, |
| 166 |
{ |
| 167 |
f: 3, |
| 168 |
}), |
| 169 |
|
| 170 |
test_field9d: f( |
| 171 |
10, |
| 172 |
{ |
| 173 |
f: 3, |
| 174 |
} |
| 175 |
), |
| 176 |
|
| 177 |
test_field9e: f(local x = 10; |
| 178 |
x + 20, { |
| 179 |
f: 3, |
| 180 |
}), |
| 181 |
|
| 182 |
test_field9g: f(local x = 10; |
| 183 |
x + 20, |
| 184 |
{ |
| 185 |
f: 3, |
| 186 |
}), |
| 187 |
|
| 188 |
local h(a, b, c) = null, |
| 189 |
test_field9h: h('blah', |
| 190 |
{ |
| 191 |
f: 3, |
| 192 |
}, |
| 193 |
'blah'), |
| 194 |
|
| 195 |
test_field10: if true then [ |
| 196 |
null, |
| 197 |
], |
| 198 |
|
| 199 |
test_field11: ( |
| 200 |
'lol' |
| 201 |
), |
| 202 |
|
| 203 |
test_field11b: (1 |
| 204 |
+ 2) + ( |
| 205 |
3 |
| 206 |
), |
| 207 |
|
| 208 |
test_field11c: ([ |
| 209 |
'foo', |
| 210 |
]), |
| 211 |
|
| 212 |
test_field12: [ |
| 213 |
1, |
| 214 |
], |
| 215 |
|
| 216 |
test_field13: [ |
| 217 |
1, |
| 218 |
2, |
| 219 |
], |
| 220 |
|
| 221 |
test_field14(obj):: if 10000 == 10000 then 'wheeeeeeeee' |
| 222 |
else if 10000 == 1000 then 'whoooooo' |
| 223 |
else 'nah', |
| 224 |
|
| 225 |
test_field14b(obj):: if 10000 == 10000 |
| 226 |
then 'wheeeeeeeee' |
| 227 |
else if 10000 == 1000 then 'whoooooo' |
| 228 |
else 'nah', |
| 229 |
|
| 230 |
test_field14c(obj):: if 10000 == 10000 |
| 231 |
then |
| 232 |
'wheeeeeeeee' |
| 233 |
else |
| 234 |
if 10000 == 1000 |
| 235 |
then 'whoooooo' |
| 236 |
else |
| 237 |
'nah', |
| 238 |
|
| 239 |
test_field15: [ |
| 240 |
{ f: 2 } |
| 241 |
for i in [] |
| 242 |
], |
| 243 |
|
| 244 |
test_field16: |
| 245 |
if true then |
| 246 |
null |
| 247 |
else [ |
| 248 |
null, |
| 249 |
], |
| 250 |
|
| 251 |
test_field16b: |
| 252 |
if true then [ |
| 253 |
null, |
| 254 |
] else |
| 255 |
null, |
| 256 |
|
| 257 |
test_field17: if true then |
| 258 |
null |
| 259 |
else [ |
| 260 |
null, |
| 261 |
], |
| 262 |
|
| 263 |
test_field17b: if true then [ |
| 264 |
null, |
| 265 |
] else |
| 266 |
null, |
| 267 |
|
| 268 |
test_field18: if true |
| 269 |
then |
| 270 |
null |
| 271 |
else [ |
| 272 |
null, |
| 273 |
], |
| 274 |
|
| 275 |
test_field18b: if true |
| 276 |
then [ |
| 277 |
null, |
| 278 |
] else |
| 279 |
null, |
| 280 |
|
| 281 |
test_field19:: [1, 2, 3][/*foo*/ 1/*bar*/:], |
| 282 |
test_field20:: [1, 2, 3][/*foo*/ 1/*bar*/:/*baz*/], |
| 283 |
|
| 284 |
prettyFields: { |
| 285 |
identifier: true, |
| 286 |
'not identifier': true, |
| 287 |
'function': true, // Test keyword. |
| 288 |
}, |
| 289 |
|
| 290 |
field: 1, |
| 291 |
|
| 292 |
dollarUnary: -$.field, |
| 293 |
|
| 294 |
objects1():: ['something'] |
| 295 |
+ if true then ['something'] |
| 296 |
else [], |
| 297 |
|
| 298 |
objects2():: ['something'] |
| 299 |
+ if true then |
| 300 |
['something'] |
| 301 |
else [], |
| 302 |
|
| 303 |
objects3():: ['something'] + if true then |
| 304 |
['something'] |
| 305 |
else [], |
| 306 |
|
| 307 |
strongIndent:: { |
| 308 |
foo: ['foo'] |
| 309 |
+ if true then [ |
| 310 |
'baz', |
| 311 |
] else [], |
| 312 |
|
| 313 |
bar: ['foo'] |
| 314 |
+ if true then |
| 315 |
['baz'] |
| 316 |
else [], |
| 317 |
|
| 318 |
fow: ['foo'] + |
| 319 |
if true then [ |
| 320 |
'baz', |
| 321 |
] else [], |
| 322 |
|
| 323 |
baw: ['foo'] + |
| 324 |
if true then |
| 325 |
['baz'] |
| 326 |
else [], |
| 327 |
|
| 328 |
fox: std.equals( |
| 329 |
['foo'], |
| 330 |
if true then [ |
| 331 |
'baz', |
| 332 |
] else [], |
| 333 |
), |
| 334 |
|
| 335 |
bax: std.equals( |
| 336 |
['foo'], |
| 337 |
if true then |
| 338 |
['baz'] |
| 339 |
else [], |
| 340 |
), |
| 341 |
|
| 342 |
foy: [ |
| 343 |
['foo'], |
| 344 |
if true then [ |
| 345 |
'baz', |
| 346 |
] else [], |
| 347 |
], |
| 348 |
|
| 349 |
bay: [ |
| 350 |
['foo'], |
| 351 |
if true then |
| 352 |
['baz'] |
| 353 |
else [], |
| 354 |
], |
| 355 |
|
| 356 |
foz: (['foo'] |
| 357 |
+ if true then [ |
| 358 |
'baz', |
| 359 |
] else []), |
| 360 |
|
| 361 |
baz: (['foo'] |
| 362 |
+ if true then |
| 363 |
['baz'] |
| 364 |
else []), |
| 365 |
}, |
| 366 |
|
| 367 |
user4: std.toString( |
| 368 |
a='value1', |
| 369 |
), |
| 370 |
} |