| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 // Test class literal expressions. | 7 // Test class literal expressions. |
| 8 | 8 |
| 9 class Class { | 9 class Class { |
| 10 static fisk() => 42; | 10 static fisk() => 42; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Expect.throws(() { Class[0]++; }, (e) => e is NoSuchMethodError); | 41 Expect.throws(() { Class[0]++; }, (e) => e is NoSuchMethodError); |
| 42 Expect.throws(() { Class.method(); }, (e) => e is NoSuchMethodError); | 42 Expect.throws(() { Class.method(); }, (e) => e is NoSuchMethodError); |
| 43 Expect.throws(() { Class.field; }, (e) => e is NoSuchMethodError); | 43 Expect.throws(() { Class.field; }, (e) => e is NoSuchMethodError); |
| 44 Expect.throws(() { var x = Class.method(); }, (e) => e is NoSuchMethodError); | 44 Expect.throws(() { var x = Class.method(); }, (e) => e is NoSuchMethodError); |
| 45 Expect.throws(() { var x = Class.field; }, (e) => e is NoSuchMethodError); | 45 Expect.throws(() { var x = Class.field; }, (e) => e is NoSuchMethodError); |
| 46 Expect.throws(() { foo(Class.method()); }, (e) => e is NoSuchMethodError); | 46 Expect.throws(() { foo(Class.method()); }, (e) => e is NoSuchMethodError); |
| 47 Expect.throws(() { foo(Class.field); }, (e) => e is NoSuchMethodError); | 47 Expect.throws(() { foo(Class.field); }, (e) => e is NoSuchMethodError); |
| 48 Expect.throws(() { Class / 3; }, (e) => e is NoSuchMethodError); | 48 Expect.throws(() { Class / 3; }, (e) => e is NoSuchMethodError); |
| 49 Expect.throws(() { Class += 3; }, (e) => e is NoSuchMethodError); | 49 Expect.throws(() { Class += 3; }, (e) => e is NoSuchMethodError); |
| 50 | 50 |
| 51 // Verify that a class literal is its runtimeType. | |
| 52 var obj = new Class(); | |
| 53 Expect.identical(Class, obj.runtimeType); | |
| 54 | |
| 55 // Verify that a class literal isn't a string literal. | 51 // Verify that a class literal isn't a string literal. |
| 56 Expect.notEquals(Class, "Class"); | 52 Expect.notEquals(Class, "Class"); |
| 57 | 53 |
| 58 // Verify toString() works for class literals. | 54 // Verify toString() works for class literals. |
| 59 Expect.equals((Class).toString(), "Class"); | 55 Expect.equals((Class).toString(), "Class"); |
| 60 var y = Class; | 56 var y = Class; |
| 61 Expect.equals(y.toString(), "Class"); | 57 Expect.equals(y.toString(), "Class"); |
| 62 | 58 |
| 63 Expect.throws(() { Class.toString(); }, (e) => e is NoSuchMethodError); | 59 Expect.throws(() { Class.toString(); }, (e) => e is NoSuchMethodError); |
| 64 } | 60 } |
| OLD | NEW |