| 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 |
std.assertEqual([], []) && |
| 18 |
std.assertEqual([1], [1]) && |
| 19 |
std.assertEqual([1], [1]) && |
| 20 |
std.assertEqual([1, 4, 9, 16][2], 9) && |
| 21 |
std.assertEqual([1, 4, 9, 16] == [1, 4, 9, 16], true) && |
| 22 |
std.assertEqual([1, 4, 9, 16] != [1, 4, 9, 15], true) && |
| 23 |
std.assertEqual([1, 4, 9, 16] == [1, 4, 9, 15], false) && |
| 24 |
std.assertEqual([1, 4, 9, 16] != [1, 4, 9, 16], false) && |
| 25 |
|
| 26 |
std.assertEqual([1, 4, 9, 16] == [1, 4, 9, 16, 17], false) && |
| 27 |
std.assertEqual([1, 4, 9, 16] != [1, 4, 9, 16, 17], true) && |
| 28 |
std.assertEqual([1, 4, 9, 16, 17] == [1, 4, 9, 16], false) && |
| 29 |
std.assertEqual([1, 4, 9, 16, 17] != [1, 4, 9, 16], true) && |
| 30 |
|
| 31 |
std.assertEqual([1, 4, 9, error 'foo'][2], 9) && |
| 32 |
std.assertEqual([] + [1, 2, 3] + [4, 5, 6] + [], [1, 2, 3, 4, 5, 6]) && |
| 33 |
std.assertEqual([] + [], []) && |
| 34 |
|
| 35 |
std.assertEqual([x * x for x in [1, 2, 3, 4]], [1, 4, 9, 16]) && |
| 36 |
std.assertEqual([x * x for x in [-3, -2, -1, 0, 1, 2, 3] if x >= 0], [0, 1, 4, 9]) && |
| 37 |
|
| 38 |
std.assertEqual([x * x for x in [-3, -2, -1, 0, 1, 2, 3] if x >= 0], [0, 1, 4, 9]) && |
| 39 |
std.assertEqual([x * x for x in []], []) && |
| 40 |
|
| 41 |
std.assertEqual(local x = 10; [x for x in [x, x, x]], [10, 10, 10]) && |
| 42 |
|
| 43 |
local arr = [ |
| 44 |
{ x: 1, y: 4, z: true }, |
| 45 |
{ x: 1, y: 4, z: false }, |
| 46 |
{ x: 1, y: 6, z: true }, |
| 47 |
{ x: 1, y: 6, z: false }, |
| 48 |
{ x: 2, y: 6, z: true }, |
| 49 |
{ x: 2, y: 6, z: false }, |
| 50 |
{ x: 3, y: 6, z: true }, |
| 51 |
{ x: 3, y: 6, z: false }, |
| 52 |
]; |
| 53 |
|
| 54 |
std.assertEqual(arr, [{ x: x, y: y, z: z } for x in [1, 2, 3] for y in [1, 4, 6] if x + 2 < y for z in [true, false]]) && |
| 55 |
|
| 56 |
|
| 57 |
true |