| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // VMOptions=-DUSE_CPS_IR=true | 4 // VMOptions=-DUSE_CPS_IR=true |
| 5 | 5 |
| 6 // Tests for basic functionality. | 6 // Tests for basic functionality. |
| 7 | 7 |
| 8 library basic_tests; | 8 library basic_tests; |
| 9 | 9 |
| 10 import 'js_backend_cps_ir.dart'; | 10 import 'js_backend_cps_ir.dart'; |
| 11 | 11 |
| 12 const List<TestEntry> tests = const [ | 12 const List<TestEntry> tests = const [ |
| 13 const TestEntry(r""" | 13 const TestEntry(r""" |
| 14 main() { | 14 main() { |
| 15 var e = 1; | 15 var e = 1; |
| 16 var l = [1, 2, 3]; | 16 var l = [1, 2, 3]; |
| 17 var m = {'s': 1}; | 17 var m = {'s': 1}; |
| 18 | 18 |
| 19 print('(' ')'); | 19 print('(' ')'); |
| 20 print('(${true})'); | 20 print('(${true})'); |
| 21 print('(${1})'); | 21 print('(${1})'); |
| 22 print('(${[1, 2, 3]})'); | 22 print('(${[1, 2, 3]})'); |
| 23 print('(${{'s': 1}})'); | 23 print('(${{'s': 1}})'); |
| 24 print('($e)'); | 24 print('($e)'); |
| 25 print('($l)'); | 25 print('($l)'); |
| 26 print('($m)'); | 26 print('($m)'); |
| 27 }""",r""" | 27 }""",r""" |
| 28 function() { | 28 function() { |
| 29 var e, l, m; | 29 var l, m; |
| 30 e = 1; | |
| 31 l = [1, 2, 3]; | 30 l = [1, 2, 3]; |
| 32 m = P.LinkedHashMap_LinkedHashMap$_literal(["s", 1]); | 31 m = P.LinkedHashMap_LinkedHashMap$_literal(["s", 1]); |
| 33 P.print("()"); | 32 P.print("()"); |
| 34 P.print("(" + true + ")"); | 33 P.print("(" + true + ")"); |
| 35 P.print("(" + 1 + ")"); | 34 P.print("(" + 1 + ")"); |
| 36 P.print("(" + H.S([1, 2, 3]) + ")"); | 35 P.print("(" + H.S([1, 2, 3]) + ")"); |
| 37 P.print("(" + H.S(P.LinkedHashMap_LinkedHashMap$_literal(["s", 1])) + ")"); | 36 P.print("(" + H.S(P.LinkedHashMap_LinkedHashMap$_literal(["s", 1])) + ")"); |
| 38 P.print("(" + H.S(e) + ")"); | 37 P.print("(" + 1 + ")"); |
| 39 P.print("(" + H.S(l) + ")"); | 38 P.print("(" + H.S(l) + ")"); |
| 40 P.print("(" + H.S(m) + ")"); | 39 P.print("(" + H.S(m) + ")"); |
| 41 return null; | 40 return null; |
| 42 }"""), | 41 }"""), |
| 43 const TestEntry(""" | 42 const TestEntry(""" |
| 44 foo(a, [b = "b"]) => b; | 43 foo(a, [b = "b"]) => b; |
| 45 bar(a, {b: "b", c: "c"}) => c; | 44 bar(a, {b: "b", c: "c"}) => c; |
| 46 main() { | 45 main() { |
| 47 foo(0); | 46 foo(0); |
| 48 foo(1, 2); | 47 foo(1, 2); |
| 49 bar(3); | 48 bar(3); |
| 50 bar(4, b: 5); | 49 bar(4, b: 5); |
| 51 bar(6, c: 7); | 50 bar(6, c: 7); |
| 52 bar(8, b: 9, c: 10); | 51 bar(8, b: 9, c: 10); |
| 53 } | 52 } |
| 54 """, | 53 """, |
| 55 """ | 54 """ |
| 56 function() { | 55 function() { |
| 57 var v0, v1; | |
| 58 V.foo(0, "b"); | 56 V.foo(0, "b"); |
| 59 V.foo(1, 2); | 57 V.foo(1, 2); |
| 60 V.bar(3, "b", "c"); | 58 V.bar(3, "b", "c"); |
| 61 V.bar(4, 5, "c"); | 59 V.bar(4, 5, "c"); |
| 62 v0 = 6; | 60 V.bar(6, "b", 7); |
| 63 v1 = 7; | |
| 64 V.bar(v0, "b", v1); | |
| 65 V.bar(8, 9, 10); | 61 V.bar(8, 9, 10); |
| 66 return null; | 62 return null; |
| 67 }"""), | 63 }"""), |
| 68 const TestEntry( | 64 const TestEntry( |
| 69 """ | 65 """ |
| 70 foo(a) { | 66 foo(a) { |
| 71 return a; | 67 return a; |
| 72 } | 68 } |
| 73 main() { | 69 main() { |
| 74 var a = 10; | 70 var a = 10; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 function() { | 129 function() { |
| 134 P.print(P.DateTime$now().isBefore$1(P.DateTime$now())); | 130 P.print(P.DateTime$now().isBefore$1(P.DateTime$now())); |
| 135 return null; | 131 return null; |
| 136 }"""), | 132 }"""), |
| 137 ]; | 133 ]; |
| 138 | 134 |
| 139 | 135 |
| 140 void main() { | 136 void main() { |
| 141 runTests(tests); | 137 runTests(tests); |
| 142 } | 138 } |
| OLD | NEW |