Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, 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 'package:async_helper/async_helper.dart'; | |
| 7 | |
| 8 import "deferred_not_loaded_check_lib.dart" deferred as lib; | |
| 9 | |
| 10 // Test that we give appropriate errors when accessing an element that is not | |
| 11 // yet loaded. | |
| 12 | |
| 13 var c; | |
| 14 | |
| 15 expectNoSideEffect(test) { | |
| 16 c = 0; | |
| 17 test(); | |
| 18 Expect.isTrue(c == 0); | |
| 19 } | |
| 20 | |
| 21 expectThrowsNotLoaded(test){ | |
| 22 Expect.throws(test, (e) => e is Error); | |
| 23 } | |
| 24 | |
| 25 int sideEffect() { | |
| 26 c = 1; | |
| 27 return 10; | |
| 28 } | |
| 29 | |
| 30 void main() { | |
| 31 expectNoSideEffect(() { | |
| 32 expectThrowsNotLoaded(() { | |
| 33 print("Calling toplevel ${lib.foo(sideEffect())}"); | |
|
floitsch
2014/04/14 12:04:08
Remove the prints.
Don't hide the code that is act
sigurdm
2014/04/22 11:22:48
Done.
| |
| 34 }); | |
| 35 }); | |
| 36 expectNoSideEffect(() { | |
| 37 expectThrowsNotLoaded(() { | |
| 38 print("Calling static ${lib.C.foo(sideEffect())}"); | |
| 39 }); | |
| 40 }); | |
| 41 expectNoSideEffect(() { | |
| 42 expectThrowsNotLoaded(() { | |
| 43 print("New-expression ${new lib.C(sideEffect())}"); | |
| 44 }); | |
| 45 }); | |
| 46 expectThrowsNotLoaded(() { | |
| 47 print("Getting var ${lib.a}"); | |
| 48 }); | |
| 49 expectNoSideEffect(() { | |
| 50 expectThrowsNotLoaded(() { | |
| 51 print("Setting var ${lib.a = sideEffect()}"); | |
| 52 }); | |
| 53 }); | |
| 54 expectThrowsNotLoaded(() { | |
| 55 print("Getter ${lib.getter}"); | |
| 56 }); | |
| 57 expectNoSideEffect(() { | |
| 58 expectThrowsNotLoaded(() { | |
| 59 print("Setter ${lib.setter = sideEffect()}"); | |
| 60 }); | |
| 61 }); | |
| 62 expectNoSideEffect(() { | |
| 63 expectThrowsNotLoaded(() { | |
| 64 print("Setter ${lib.list[sideEffect()] = sideEffect()}"); | |
| 65 }); | |
| 66 }); | |
| 67 expectNoSideEffect(() { | |
| 68 expectThrowsNotLoaded(() { | |
| 69 print("Non-function static call ${lib.closure(sideEffect())}"); | |
| 70 }); | |
| 71 }); | |
| 72 } | |
| OLD | NEW |