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