| 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 | 4 |
| 5 // Tests of operators. | 5 // Tests of operators. |
| 6 | 6 |
| 7 library operators_tests; | 7 library operators_tests; |
| 8 | 8 |
| 9 import 'js_backend_cps_ir.dart'; | 9 import 'js_backend_cps_ir.dart'; |
| 10 | 10 |
| 11 const List<TestEntry> tests = const [ | 11 const List<TestEntry> tests = const [ |
| 12 const TestEntry("main() { return true ? 42 : 'foo'; }"), | 12 const TestEntry("main() { return true ? 42 : 'foo'; }"), |
| 13 const TestEntry(""" | 13 const TestEntry(""" |
| 14 foo() => foo(); | 14 var x = 1; |
| 15 foo() => ++x > 10; |
| 15 main() { | 16 main() { |
| 16 print(foo() ? "hello world" : "bad bad"); | 17 print(foo() ? "hello world" : "bad bad"); |
| 17 }""",""" | 18 }""",""" |
| 18 function() { | 19 function() { |
| 19 P.print(V.foo() ? "hello world" : "bad bad"); | 20 P.print(V.foo() ? "hello world" : "bad bad"); |
| 20 }"""), | 21 }"""), |
| 21 const TestEntry(""" | 22 const TestEntry(""" |
| 22 foo() { print('foo'); } | 23 var x = 1; |
| 24 foo() => ++x > 10; |
| 23 main() { | 25 main() { |
| 24 print(foo() ? "hello world" : "bad bad"); | 26 print(foo() ? "hello world" : "bad bad"); |
| 25 }""",""" | 27 }""",""" |
| 26 function() { | 28 function() { |
| 27 V.foo(); | 29 P.print(V.foo() ? "hello world" : "bad bad"); |
| 28 P.print("bad bad"); | |
| 29 }"""), | 30 }"""), |
| 30 const TestEntry(""" | 31 const TestEntry(""" |
| 31 get foo => foo; | 32 var x = 1; |
| 33 get foo => ++x > 10; |
| 32 main() { | 34 main() { |
| 33 print(foo ? "hello world" : "bad bad"); | 35 print(foo ? "hello world" : "bad bad"); |
| 34 }""",""" | 36 }""",""" |
| 35 function() { | 37 function() { |
| 36 P.print(V.foo() ? "hello world" : "bad bad"); | 38 P.print(V.foo() ? "hello world" : "bad bad"); |
| 37 }"""), | 39 }"""), |
| 38 const TestEntry(""" | 40 const TestEntry(""" |
| 39 get foo => foo; | 41 var x = 1; |
| 42 get foo => ++x > 10; |
| 40 main() { print(foo && foo); } | 43 main() { print(foo && foo); } |
| 41 """, """ | 44 """, """ |
| 42 function() { | 45 function() { |
| 43 P.print(V.foo() ? !!V.foo() : false); | 46 P.print(V.foo() ? !!V.foo() : false); |
| 44 }"""), | 47 }"""), |
| 45 const TestEntry(""" | 48 const TestEntry(""" |
| 46 get foo => foo; | 49 var x = 1; |
| 50 get foo => ++x > 10; |
| 47 main() { print(foo || foo); } | 51 main() { print(foo || foo); } |
| 48 """,""" | 52 """,""" |
| 49 function() { | 53 function() { |
| 50 P.print(V.foo() ? true : !!V.foo()); | 54 P.print(V.foo() ? true : !!V.foo()); |
| 51 }"""), | 55 }"""), |
| 56 const TestEntry(""" |
| 57 get foo => foo; |
| 58 main() { print(foo || foo); } |
| 59 """,""" |
| 60 function() { |
| 61 V.foo(); |
| 62 }"""), |
| 52 | 63 |
| 53 // Needs interceptor calling convention | 64 // Needs interceptor calling convention |
| 54 //const TestEntry(""" | 65 //const TestEntry(""" |
| 55 //class Foo { | 66 //class Foo { |
| 56 // operator[]=(index, value) { | 67 // operator[]=(index, value) { |
| 57 // print(value); | 68 // print(value); |
| 58 // } | 69 // } |
| 59 //} | 70 //} |
| 60 //main() { | 71 //main() { |
| 61 // var foo = new Foo(); | 72 // var foo = new Foo(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 77 if (v0 < 0 || v0 >= list.length) | 88 if (v0 < 0 || v0 >= list.length) |
| 78 H.ioore(list, v0); | 89 H.ioore(list, v0); |
| 79 list[v0] = 6; | 90 list[v0] = 6; |
| 80 P.print(list); | 91 P.print(list); |
| 81 }"""), | 92 }"""), |
| 82 ]; | 93 ]; |
| 83 | 94 |
| 84 void main() { | 95 void main() { |
| 85 runTests(tests); | 96 runTests(tests); |
| 86 } | 97 } |
| OLD | NEW |