OLD | NEW |
1 import 'dart:html'; | 1 import 'dart:html'; |
2 import 'package:js/js.dart'; | 2 import 'package:js/js.dart'; |
3 import 'package:expect/expect.dart'; | 3 import 'package:expect/expect.dart'; |
4 | 4 |
5 @JS() | 5 @JS() |
6 class A { | 6 class A { |
7 external get foo; | 7 external get foo; |
8 | 8 |
9 external A(var foo); | 9 external A(var foo); |
10 } | 10 } |
11 | 11 |
12 class F { | 12 class F { |
13 final foo; | 13 final foo; |
14 | 14 |
15 F(this.foo); | 15 F(this.foo); |
16 } | 16 } |
17 | 17 |
18 @NoInline() | 18 @NoInline() |
19 testA(A o) { | 19 testA(A o) { |
20 return o.foo; | 20 return o.foo; |
21 } | 21 } |
22 | 22 |
23 @NoInline() | 23 @NoInline() |
24 testF(F o) { | 24 testF(F o) { |
25 return o.foo; | 25 return o.foo; |
26 } | 26 } |
27 | 27 |
28 | |
29 _injectJs() { | 28 _injectJs() { |
30 document.body.append(new ScriptElement() | 29 document.body.append(new ScriptElement() |
31 ..type = 'text/javascript' | 30 ..type = 'text/javascript' |
32 ..innerHtml = r""" | 31 ..innerHtml = r""" |
33 function A(foo) { | 32 function A(foo) { |
34 this.foo = foo; | 33 this.foo = foo; |
35 } | 34 } |
36 """); | 35 """); |
37 } | 36 } |
38 | 37 |
39 void expectValueOrTypeError(f(), value) { | 38 void expectValueOrTypeError(f(), value) { |
40 try { | 39 try { |
41 var i = 0; | 40 var i = 0; |
42 String s = i; // Test for checked mode. | 41 String s = i; // Test for checked mode. |
43 Expect.equals(f(), value); | 42 Expect.equals(f(), value); |
44 } on TypeError catch (error) { | 43 } on TypeError catch (error) { |
45 Expect.throws(f, (ex) => ex is TypeError); | 44 Expect.throws(f, (ex) => ex is TypeError); |
46 } | 45 } |
47 } | 46 } |
48 | 47 |
49 main() { | 48 main() { |
50 _injectJs(); | 49 _injectJs(); |
51 | 50 |
52 var a = new A(1); | 51 var a = new A(1); |
53 var f = new F(6); | 52 var f = new F(6); |
54 | 53 |
55 Expect.equals(testA(a), 1); | 54 Expect.equals(testA(a), 1); |
56 Expect.equals(testF(f), 6); //# 01: ok | 55 Expect.equals(testF(f), 6); //# 01: ok |
57 } | 56 } |
58 | |
59 | |
OLD | NEW |