| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Tests for basic functionality. | |
| 6 | |
| 7 library basic_tests; | |
| 8 | |
| 9 import 'js_backend_cps_ir_test.dart'; | |
| 10 | |
| 11 const List<TestEntry> tests = const [ | |
| 12 const TestEntry(""" | |
| 13 foo(a, [b = "b"]) => b; | |
| 14 bar(a, {b: "b", c: "c"}) => c; | |
| 15 main() { | |
| 16 foo(0); | |
| 17 foo(0, 1); | |
| 18 bar(0); | |
| 19 bar(0, b: 1); | |
| 20 bar(0, c: 1); | |
| 21 bar(0, b: 1, c: 2); | |
| 22 } | |
| 23 """, | |
| 24 """ | |
| 25 function() { | |
| 26 V.foo(0, "b"); | |
| 27 V.foo(0, 1); | |
| 28 V.bar(0, "b", "c"); | |
| 29 V.bar(0, 1, "c"); | |
| 30 V.bar(0, "b", 1); | |
| 31 V.bar(0, 1, 2); | |
| 32 return null; | |
| 33 }"""), | |
| 34 const TestEntry( | |
| 35 """ | |
| 36 foo(a) { | |
| 37 return a; | |
| 38 } | |
| 39 main() { | |
| 40 var a = 10; | |
| 41 var b = 1; | |
| 42 var t; | |
| 43 t = a; | |
| 44 a = b; | |
| 45 b = t; | |
| 46 print(a); | |
| 47 print(b); | |
| 48 print(b); | |
| 49 print(foo(a)); | |
| 50 } | |
| 51 """, | |
| 52 """ | |
| 53 function() { | |
| 54 var a, b; | |
| 55 a = 10; | |
| 56 b = 1; | |
| 57 P.print(b); | |
| 58 P.print(a); | |
| 59 P.print(a); | |
| 60 P.print(V.foo(b)); | |
| 61 return null; | |
| 62 }"""), | |
| 63 const TestEntry( | |
| 64 """ | |
| 65 foo() { return 42; } | |
| 66 main() { return foo(); } | |
| 67 """, | |
| 68 """function() { | |
| 69 return V.foo(); | |
| 70 }"""), | |
| 71 const TestEntry("main() {}"), | |
| 72 const TestEntry("main() { return 42; }"), | |
| 73 const TestEntry("main() { return; }", """ | |
| 74 function() { | |
| 75 return null; | |
| 76 }"""), | |
| 77 // Constructor invocation | |
| 78 const TestEntry(""" | |
| 79 main() { | |
| 80 print(new Set()); | |
| 81 print(new Set.from([1, 2, 3])); | |
| 82 }""", r""" | |
| 83 function() { | |
| 84 P.print(P.Set_Set()); | |
| 85 P.print(P.Set_Set$from([1, 2, 3])); | |
| 86 return null; | |
| 87 }"""), | |
| 88 // Call synthetic constructor. | |
| 89 const TestEntry(""" | |
| 90 class C {} | |
| 91 main() { | |
| 92 print(new C()); | |
| 93 }"""), | |
| 94 // Method invocation | |
| 95 const TestEntry(""" | |
| 96 main() { | |
| 97 print(new DateTime.now().isBefore(new DateTime.now())); | |
| 98 }""", r""" | |
| 99 function() { | |
| 100 P.print(P.DateTime$now().isBefore$1(P.DateTime$now())); | |
| 101 return null; | |
| 102 }"""), | |
| 103 ]; | |
| OLD | NEW |