| 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 // We need to define a foo method so that Frog sees it. Because it's | |
| 23 // the only occurence of 'foo', Frog does not bother mangling the | |
| 24 // call sites. It thinks all calls will either go to this method, or | |
| 25 // throw a NoSuchMethodError. | |
| 26 foo() { return 42; } | |
| 27 } | |
| 28 | |
| 29 typedContext() { | |
| 30 var things = [ makeA(), new B() ]; | |
| 31 A a = things[0]; | |
| 32 Expect.throws(() => a.foo(), | |
| 33 (e) => e is NoSuchMethodError); | |
| 34 Expect.throws(() => a.foo, | |
| 35 (e) => e is NoSuchMethodError); | |
| 36 Expect.throws(() => a.foo = 4, | |
| 37 (e) => e is NoSuchMethodError); | |
| 38 } | |
| 39 | |
| 40 untypedContext() { | |
| 41 var things = [ makeA(), new B() ]; | |
| 42 var a = things[0]; | |
| 43 Expect.throws(() => a.foo(), | |
| 44 (e) => e is NoSuchMethodError); | |
| 45 Expect.throws(() => a.foo, | |
| 46 (e) => e is NoSuchMethodError); | |
| 47 Expect.throws(() => a.foo = 4, | |
| 48 (e) => e is NoSuchMethodError); | |
| 49 } | |
| 50 | |
| 51 main() { | |
| 52 setup(); | |
| 53 typedContext(); | |
| 54 untypedContext(); | |
| 55 } | |
| OLD | NEW |