| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'mock_compiler.dart'; | 6 import 'mock_compiler.dart'; |
| 7 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' as jsAst; | 7 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' as jsAst; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' show js; | 8 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' show js; |
| 9 | 9 |
| 10 void testExpression(String expression, [String expect = ""]) { | 10 void testExpression(String expression, [String expect = ""]) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // *Can't handle non-empty object literals | 98 // *Can't handle non-empty object literals |
| 99 testError('foo({meaning: 42})', 'Expected RBRACE'); | 99 testError('foo({meaning: 42})', 'Expected RBRACE'); |
| 100 // Literals. | 100 // Literals. |
| 101 testExpression('x(false, true, null)'); | 101 testExpression('x(false, true, null)'); |
| 102 // *We should really throw here. | 102 // *We should really throw here. |
| 103 testExpression('var false = 42'); | 103 testExpression('var false = 42'); |
| 104 testExpression('var new = 42'); | 104 testExpression('var new = 42'); |
| 105 // Bad keyword. | 105 // Bad keyword. |
| 106 testError('var typeof = 42', "Expected ALPHA"); | 106 testError('var typeof = 42', "Expected ALPHA"); |
| 107 // Malformed decimal/hex. | 107 // Malformed decimal/hex. |
| 108 testError('var x = 42.', "Unparseable number"); | |
| 109 testError('var x = 1.1.1', "Unparseable number"); | 108 testError('var x = 1.1.1', "Unparseable number"); |
| 110 testError('var x = 0xabcdefga', "Unparseable number"); | 109 testError('var x = 0xabcdefga', "Unparseable number"); |
| 111 testError('var x = 0xabcdef\$a', "Unparseable number"); | 110 testError('var x = 0xabcdef\$a', "Unparseable number"); |
| 112 testError('var x = 0x ', "Unparseable number"); | 111 testError('var x = 0x ', "Unparseable number"); |
| 113 // Good hex constants. | 112 // Good hex constants. |
| 114 testExpression('var x = 0xff'); | 113 testExpression('var x = 0xff'); |
| 115 testExpression('var x = 0xff + 0xff'); | 114 testExpression('var x = 0xff + 0xff'); |
| 116 testExpression('var x = 0xaF + 0x0123456789abcdefABCDEF'); | 115 testExpression('var x = 0xaF + 0x0123456789abcdefABCDEF'); |
| 117 // All sorts of keywords are allowed as property names in ES5. | 116 // All sorts of keywords are allowed as property names in ES5. |
| 118 testExpression('x.new = 0'); | 117 testExpression('x.new = 0'); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 testExpression("y = a == null ? b : a"); | 180 testExpression("y = a == null ? b : a"); |
| 182 testExpression("y = a == null ? b + c : a + c"); | 181 testExpression("y = a == null ? b + c : a + c"); |
| 183 testExpression("foo = a ? b : c ? d : e"); | 182 testExpression("foo = a ? b : c ? d : e"); |
| 184 testExpression("foo = a ? b ? c : d : e"); | 183 testExpression("foo = a ? b ? c : d : e"); |
| 185 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z"); | 184 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z"); |
| 186 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z"); | 185 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z"); |
| 187 // Stacked assignment. | 186 // Stacked assignment. |
| 188 testExpression("a = b = c"); | 187 testExpression("a = b = c"); |
| 189 testExpression("var a = b = c"); | 188 testExpression("var a = b = c"); |
| 190 } | 189 } |
| OLD | NEW |