| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 foo({fisk}) { | 5 foo({fisk}) { |
| 6 print(fisk); | 6 print(fisk); |
| 7 } | 7 } |
| 8 | 8 |
| 9 caller(f) { | 9 caller(f) { |
| 10 f(); | 10 f(); |
| 11 } | 11 } |
| 12 | 12 |
| 13 main() { | 13 main() { |
| 14 int i = 0; | 14 int i = 0; |
| 15 print(i == 1 ? "bad" : "good"); | 15 print(i == 1 ? "bad" : "good"); |
| 16 print("$i"); | 16 print("$i"); |
| 17 print("'$i'"); | 17 print("'$i'"); |
| 18 print(" '${i}' "); | 18 print(" '${i}' "); |
| 19 print(" '${i}' '${i}'"); | 19 print(" '${i}' '${i}'"); |
| 20 print(" '$i' '${i}'"); | 20 print(" '$i' '${i}'"); |
| 21 print("foo" "bar"); | 21 print("foo" "bar"); |
| 22 print(" '${i}' '${i}'" " '$i' '${i}'"); | 22 print(" '${i}' '${i}'" " '$i' '${i}'"); |
| 23 try { | 23 try { |
| 24 throw "fisk"; | 24 throw "fisk"; |
| 25 } on String catch (e, s) { | 25 } on String catch (e, s) { |
| 26 print(e); | 26 print(e); |
| 27 if (s != null) print(s); | 27 if (s != null) print(s); |
| 28 } | 28 } |
| 29 for(;false;) {} | 29 for (; false;) {} |
| 30 var list = ["Hello, World!"]; | 30 var list = ["Hello, World!"]; |
| 31 print(list[i]); | 31 print(list[i]); |
| 32 list[i] = "Hello, Brave New World!"; | 32 list[i] = "Hello, Brave New World!"; |
| 33 print(list[i]); | 33 print(list[i]); |
| 34 i = 87; | 34 i = 87; |
| 35 print(-i); | 35 print(-i); |
| 36 print(~i); | 36 print(~i); |
| 37 print(!(i == 42)); | 37 print(!(i == 42)); |
| 38 print(--i); | 38 print(--i); |
| 39 print(++i); | 39 print(++i); |
| 40 print(i--); | 40 print(i--); |
| 41 print(i++); | 41 print(i++); |
| 42 print(new Object()); | 42 print(new Object()); |
| 43 print(const Object()); | 43 print(const Object()); |
| 44 print((new List<String>(2)).runtimeType); | 44 print((new List<String>(2)).runtimeType); |
| 45 foo(fisk: "Blorp gulp"); | 45 foo(fisk: "Blorp gulp"); |
| 46 f() { | 46 f() { |
| 47 print("f was called"); | 47 print("f was called"); |
| 48 } | 48 } |
| 49 |
| 49 caller(f); | 50 caller(f); |
| 50 caller(() { | 51 caller(() { |
| 51 print("<anon> was called"); | 52 print("<anon> was called"); |
| 52 }); | 53 }); |
| 53 g([message]) { | 54 g([message]) { |
| 54 print(message); | 55 print(message); |
| 55 } | 56 } |
| 57 |
| 56 g("Hello, World"); | 58 g("Hello, World"); |
| 57 caller(([x]) { | 59 caller(([x]) { |
| 58 print("<anon> was called with $x"); | 60 print("<anon> was called with $x"); |
| 59 }); | 61 }); |
| 60 h({message}) { | 62 h({message}) { |
| 61 print(message); | 63 print(message); |
| 62 } | 64 } |
| 65 |
| 63 h(message: "Hello, World"); | 66 h(message: "Hello, World"); |
| 64 caller(({x}) { | 67 caller(({x}) { |
| 65 print("<anon> was called with $x"); | 68 print("<anon> was called with $x"); |
| 66 }); | 69 }); |
| 67 print((int).toString()); | 70 print((int).toString()); |
| 68 print(int); | 71 print(int); |
| 69 print(int..toString()); | 72 print(int..toString()); |
| 70 try { | 73 try { |
| 71 print(int?.toString()); | 74 print(int?.toString()); |
| 72 throw "Shouldn't work"; | 75 throw "Shouldn't work"; |
| 73 } on NoSuchMethodError catch (e) { | 76 } on NoSuchMethodError catch (e) { |
| 74 print("As expected: $e"); | 77 print("As expected: $e"); |
| 75 } | 78 } |
| 76 print(int.parse("42")); | 79 print(int.parse("42")); |
| 77 } | 80 } |
| OLD | NEW |