OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/lazy_static_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__lazy_static_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const lazy_static_test = Object.create(null); |
| 11 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 12 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 13 dart.defineLazy(lazy_static_test, { |
| 14 get x() { |
| 15 return lazy_static_test.foo(); |
| 16 } |
| 17 }); |
| 18 dart.defineLazy(lazy_static_test, { |
| 19 get y() { |
| 20 return dart.dcall(lazy_static_test.y2, lazy_static_test.y3); |
| 21 } |
| 22 }); |
| 23 dart.defineLazy(lazy_static_test, { |
| 24 get y2() { |
| 25 return lazy_static_test.incrementCreator(); |
| 26 } |
| 27 }); |
| 28 dart.defineLazy(lazy_static_test, { |
| 29 get y3() { |
| 30 return lazy_static_test.fib(5); |
| 31 } |
| 32 }); |
| 33 lazy_static_test.foo = function() { |
| 34 return 499; |
| 35 }; |
| 36 dart.fn(lazy_static_test.foo, VoidTodynamic()); |
| 37 lazy_static_test.incrementCreator = function() { |
| 38 return dart.fn(x => dart.dsend(x, '+', 1), dynamicTodynamic()); |
| 39 }; |
| 40 dart.fn(lazy_static_test.incrementCreator, VoidTodynamic()); |
| 41 lazy_static_test.fib = function(x) { |
| 42 if (dart.test(dart.dsend(x, '<', 2))) return x; |
| 43 return dart.dsend(lazy_static_test.fib(dart.dsend(x, '-', 1)), '+', lazy_sta
tic_test.fib(dart.dsend(x, '-', 2))); |
| 44 }; |
| 45 dart.fn(lazy_static_test.fib, dynamicTodynamic()); |
| 46 lazy_static_test.count = 0; |
| 47 lazy_static_test.sideEffect = function() { |
| 48 return (() => { |
| 49 let x = lazy_static_test.count; |
| 50 lazy_static_test.count = dart.notNull(x) + 1; |
| 51 return x; |
| 52 })(); |
| 53 }; |
| 54 dart.fn(lazy_static_test.sideEffect, VoidTodynamic()); |
| 55 dart.defineLazy(lazy_static_test, { |
| 56 get t() { |
| 57 return lazy_static_test.sideEffect(); |
| 58 } |
| 59 }); |
| 60 dart.defineLazy(lazy_static_test, { |
| 61 get t2() { |
| 62 return lazy_static_test.sideEffect(); |
| 63 }, |
| 64 set t2(_) {} |
| 65 }); |
| 66 lazy_static_test.A = class A extends core.Object { |
| 67 static toto() { |
| 68 return 666; |
| 69 } |
| 70 static decrementCreator() { |
| 71 return dart.fn(x => dart.dsend(x, '-', 1), dynamicTodynamic()); |
| 72 } |
| 73 static fact(x) { |
| 74 if (dart.test(dart.dsend(x, '<=', 1))) return x; |
| 75 return dart.dsend(x, '*', lazy_static_test.A.fact(dart.dsend(x, '-', 1))); |
| 76 } |
| 77 }; |
| 78 dart.setSignature(lazy_static_test.A, { |
| 79 statics: () => ({ |
| 80 toto: dart.definiteFunctionType(dart.dynamic, []), |
| 81 decrementCreator: dart.definiteFunctionType(dart.dynamic, []), |
| 82 fact: dart.definiteFunctionType(dart.dynamic, [dart.dynamic]) |
| 83 }), |
| 84 names: ['toto', 'decrementCreator', 'fact'] |
| 85 }); |
| 86 dart.defineLazy(lazy_static_test.A, { |
| 87 get a() { |
| 88 return lazy_static_test.A.toto(); |
| 89 }, |
| 90 get b() { |
| 91 return dart.dcall(lazy_static_test.A.b2, lazy_static_test.A.b3); |
| 92 }, |
| 93 get b2() { |
| 94 return lazy_static_test.A.decrementCreator(); |
| 95 }, |
| 96 get b3() { |
| 97 return lazy_static_test.A.fact(5); |
| 98 } |
| 99 }); |
| 100 lazy_static_test.main = function() { |
| 101 expect$.Expect.equals(499, lazy_static_test.x); |
| 102 expect$.Expect.equals(6, lazy_static_test.y); |
| 103 expect$.Expect.equals(666, lazy_static_test.A.a); |
| 104 expect$.Expect.equals(119, lazy_static_test.A.b); |
| 105 expect$.Expect.equals(0, lazy_static_test.t); |
| 106 lazy_static_test.t2 = 499; |
| 107 expect$.Expect.equals(499, lazy_static_test.t2); |
| 108 expect$.Expect.equals(1, lazy_static_test.count); |
| 109 }; |
| 110 dart.fn(lazy_static_test.main, VoidTodynamic()); |
| 111 // Exports: |
| 112 exports.lazy_static_test = lazy_static_test; |
| 113 }); |
OLD | NEW |