| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; | |
| 6 import 'native_metadata.dart'; | |
| 7 | |
| 8 @Native("*A") | |
| 9 class A { | |
| 10 } | |
| 11 | |
| 12 @native makeA(); | |
| 13 | |
| 14 @Native(""" | |
| 15 function A() {}; | |
| 16 A.prototype.foo = function() { return 42; } | |
| 17 makeA = function() { return new A; } | |
| 18 """) | |
| 19 void setup(); | |
| 20 | |
| 21 class B { | |
| 22 foo() { return 42; } | |
| 23 } | |
| 24 | |
| 25 class C { | |
| 26 // By having two 'foo' defined in the application, Frog will mangle | |
| 27 // all calls to 'foo', which makes this test pass. | |
| 28 foo(x) { return 43; } | |
| 29 } | |
| 30 | |
| 31 typedContext() { | |
| 32 var things = [ makeA(), new B() ]; | |
| 33 A a = things[0]; | |
| 34 Expect.throws(() => a.foo(), | |
| 35 (e) => e is NoSuchMethodError); | |
| 36 Expect.throws(() => a.foo, | |
| 37 (e) => e is NoSuchMethodError); | |
| 38 Expect.throws(() => a.foo = 4, | |
| 39 (e) => e is NoSuchMethodError); | |
| 40 } | |
| 41 | |
| 42 untypedContext() { | |
| 43 var things = [ makeA(), new B() ]; | |
| 44 var a = things[0]; | |
| 45 Expect.throws(() => a.foo(), | |
| 46 (e) => e is NoSuchMethodError); | |
| 47 Expect.throws(() => a.foo, | |
| 48 (e) => e is NoSuchMethodError); | |
| 49 Expect.throws(() => a.foo = 4, | |
| 50 (e) => e is NoSuchMethodError); | |
| 51 } | |
| 52 | |
| 53 main() { | |
| 54 setup(); | |
| 55 typedContext(); | |
| 56 untypedContext(); | |
| 57 } | |
| OLD | NEW |