| 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 of operators. | |
| 6 | |
| 7 library operators_tests; | |
| 8 | |
| 9 import 'js_backend_cps_ir.dart'; | |
| 10 | |
| 11 const List<TestEntry> tests = const [ | |
| 12 const TestEntry("main() { return true ? 42 : 'foo'; }"), | |
| 13 const TestEntry(""" | |
| 14 var x = 1; | |
| 15 foo() => ++x > 10; | |
| 16 main() { | |
| 17 print(foo() ? "hello world" : "bad bad"); | |
| 18 }""",r""" | |
| 19 function() { | |
| 20 var v0 = $.x + 1; | |
| 21 $.x = v0; | |
| 22 v0 = v0 > 10 ? "hello world" : "bad bad"; | |
| 23 if (typeof dartPrint == "function") | |
| 24 dartPrint(v0); | |
| 25 else if (typeof console == "object" && typeof console.log != "undefined") | |
| 26 console.log(v0); | |
| 27 else if (!(typeof window == "object")) { | |
| 28 if (!(typeof print == "function")) | |
| 29 throw "Unable to print message: " + String(v0); | |
| 30 print(v0); | |
| 31 } | |
| 32 }"""), | |
| 33 const TestEntry(""" | |
| 34 var x = 1; | |
| 35 get foo => ++x > 10; | |
| 36 main() { | |
| 37 print(foo ? "hello world" : "bad bad"); | |
| 38 }""",r""" | |
| 39 function() { | |
| 40 var v0 = $.x + 1; | |
| 41 $.x = v0; | |
| 42 v0 = v0 > 10 ? "hello world" : "bad bad"; | |
| 43 if (typeof dartPrint == "function") | |
| 44 dartPrint(v0); | |
| 45 else if (typeof console == "object" && typeof console.log != "undefined") | |
| 46 console.log(v0); | |
| 47 else if (!(typeof window == "object")) { | |
| 48 if (!(typeof print == "function")) | |
| 49 throw "Unable to print message: " + String(v0); | |
| 50 print(v0); | |
| 51 } | |
| 52 }"""), | |
| 53 const TestEntry(""" | |
| 54 var x = 1; | |
| 55 get foo => ++x > 10; | |
| 56 main() { print(foo && foo); } | |
| 57 """, r""" | |
| 58 function() { | |
| 59 var v0 = $.x + 1; | |
| 60 $.x = v0; | |
| 61 if (v0 > 10) { | |
| 62 $.x = v0 = $.x + 1; | |
| 63 v0 = v0 > 10; | |
| 64 } else | |
| 65 v0 = false; | |
| 66 v0 = H.S(v0); | |
| 67 if (typeof dartPrint == "function") | |
| 68 dartPrint(v0); | |
| 69 else if (typeof console == "object" && typeof console.log != "undefined") | |
| 70 console.log(v0); | |
| 71 else if (!(typeof window == "object")) { | |
| 72 if (!(typeof print == "function")) | |
| 73 throw "Unable to print message: " + String(v0); | |
| 74 print(v0); | |
| 75 } | |
| 76 }"""), | |
| 77 const TestEntry(""" | |
| 78 var x = 1; | |
| 79 get foo => ++x > 10; | |
| 80 main() { print(foo || foo); } | |
| 81 """,r""" | |
| 82 function() { | |
| 83 var v0 = $.x + 1; | |
| 84 $.x = v0; | |
| 85 if (v0 > 10) | |
| 86 v0 = true; | |
| 87 else { | |
| 88 $.x = v0 = $.x + 1; | |
| 89 v0 = v0 > 10; | |
| 90 } | |
| 91 v0 = H.S(v0); | |
| 92 if (typeof dartPrint == "function") | |
| 93 dartPrint(v0); | |
| 94 else if (typeof console == "object" && typeof console.log != "undefined") | |
| 95 console.log(v0); | |
| 96 else if (!(typeof window == "object")) { | |
| 97 if (!(typeof print == "function")) | |
| 98 throw "Unable to print message: " + String(v0); | |
| 99 print(v0); | |
| 100 } | |
| 101 }"""), | |
| 102 const TestEntry(""" | |
| 103 get foo => foo; | |
| 104 main() { print(foo || foo); } | |
| 105 """,""" | |
| 106 function() { | |
| 107 V.foo(); | |
| 108 }"""), | |
| 109 | |
| 110 // Needs interceptor calling convention | |
| 111 //const TestEntry(""" | |
| 112 //class Foo { | |
| 113 // operator[]=(index, value) { | |
| 114 // print(value); | |
| 115 // } | |
| 116 //} | |
| 117 //main() { | |
| 118 // var foo = new Foo(); | |
| 119 // foo[5] = 6; | |
| 120 //}""", r""" | |
| 121 //function() { | |
| 122 // V.Foo$().$indexSet(5, 6); | |
| 123 //} | |
| 124 //"""), | |
| 125 | |
| 126 const TestEntry(""" | |
| 127 main() { | |
| 128 var list = [1, 2, 3]; | |
| 129 list[1] = 6; | |
| 130 print(list); | |
| 131 }""", r""" | |
| 132 function() { | |
| 133 var list = [1, 2, 3], v0; | |
| 134 list[1] = 6; | |
| 135 if (!(typeof (v0 = P.IterableBase_iterableToFullString(list, "[", "]")) === "s
tring")) | |
| 136 throw H.wrapException(H.argumentErrorValue(list)); | |
| 137 if (typeof dartPrint == "function") | |
| 138 dartPrint(v0); | |
| 139 else if (typeof console == "object" && typeof console.log != "undefined") | |
| 140 console.log(v0); | |
| 141 else if (!(typeof window == "object")) { | |
| 142 if (!(typeof print == "function")) | |
| 143 throw "Unable to print message: " + String(v0); | |
| 144 print(v0); | |
| 145 } | |
| 146 }"""), | |
| 147 ]; | |
| 148 | |
| 149 void main() { | |
| 150 runTests(tests); | |
| 151 } | |
| OLD | NEW |