OLD | NEW |
1 dart_library.library('opassign', null, /* Imports */[ | 1 dart_library.library('opassign', null, /* Imports */[ |
2 'dart/_runtime', | 2 'dart/_runtime', |
3 'dart/core' | 3 'dart/core' |
4 ], /* Lazy imports */[ | 4 ], /* Lazy imports */[ |
5 ], function(exports, dart, core) { | 5 ], function(exports, dart, core) { |
6 'use strict'; | 6 'use strict'; |
7 let dartx = dart.dartx; | 7 let dartx = dart.dartx; |
8 dart.copyProperties(exports, { | 8 dart.copyProperties(exports, { |
9 get index() { | 9 get index() { |
10 core.print('called "index" getter'); | 10 core.print('called "index" getter'); |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 }); | 24 }); |
25 class Foo extends core.Object { | 25 class Foo extends core.Object { |
26 Foo() { | 26 Foo() { |
27 this.x = 100; | 27 this.x = 100; |
28 } | 28 } |
29 } | 29 } |
30 function main() { | 30 function main() { |
31 let f = dart.map([0, 40]); | 31 let f = dart.map([0, 40]); |
32 core.print('should only call "index" 2 times:'); | 32 core.print('should only call "index" 2 times:'); |
33 let i = exports.index; | 33 let i = dart.as(exports.index, core.int); |
34 f[dartx.set](i, dart.dsend(f[dartx.get](i), '+', 1)); | 34 f[dartx.set](i, dart.notNull(f[dartx.get](i)) + 1); |
35 forcePostfix((() => { | 35 forcePostfix((() => { |
36 let i = exports.index, x = f[dartx.get](i); | 36 let i = dart.as(exports.index, core.int), x = f[dartx.get](i); |
37 f[dartx.set](i, dart.dsend(x, '+', 1)); | 37 f[dartx.set](i, dart.notNull(x) + 1); |
38 return x; | 38 return x; |
39 })()); | 39 })()); |
40 core.print('should only call "foo" 2 times:'); | 40 core.print('should only call "foo" 2 times:'); |
41 let o = exports.foo; | 41 let o = exports.foo; |
42 dart.dput(o, 'x', dart.dsend(dart.dload(o, 'x'), '+', 1)); | 42 dart.dput(o, 'x', dart.dsend(dart.dload(o, 'x'), '+', 1)); |
43 forcePostfix((() => { | 43 forcePostfix((() => { |
44 let o = exports.foo, x = dart.dload(o, 'x'); | 44 let o = exports.foo, x = dart.dload(o, 'x'); |
45 dart.dput(o, 'x', dart.dsend(x, '+', 1)); | 45 dart.dput(o, 'x', dart.dsend(x, '+', 1)); |
46 return x; | 46 return x; |
47 })()); | 47 })()); |
48 core.print('op assign test, should only call "index" twice:'); | 48 core.print('op assign test, should only call "index" twice:'); |
49 let i$ = exports.index; | 49 let i$ = dart.as(exports.index, core.int); |
50 f[dartx.set](i$, dart.dsend(f[dartx.get](i$), '+', f[dartx.get](exports.inde
x))); | 50 f[dartx.set](i$, dart.notNull(f[dartx.get](i$)) + dart.notNull(f[dartx.get](
exports.index))); |
51 } | 51 } |
52 dart.fn(main); | 52 dart.fn(main); |
53 function forcePostfix(x) { | 53 function forcePostfix(x) { |
54 } | 54 } |
55 dart.fn(forcePostfix); | 55 dart.fn(forcePostfix); |
56 // Exports: | 56 // Exports: |
57 exports.Foo = Foo; | 57 exports.Foo = Foo; |
58 exports.main = main; | 58 exports.main = main; |
59 exports.forcePostfix = forcePostfix; | 59 exports.forcePostfix = forcePostfix; |
60 }); | 60 }); |
OLD | NEW |