| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
| 7 | 7 |
| 8 import "deferred_not_loaded_check_lib.dart" deferred as lib; | 8 import "deferred_not_loaded_check_lib.dart" deferred as lib; |
| 9 | 9 |
| 10 // Test that we give appropriate errors when accessing an element that is not | 10 // Test that we give appropriate errors when accessing an element that is not |
| 11 // yet loaded. | 11 // yet loaded. |
| 12 | 12 |
| 13 var c; | 13 var c; |
| 14 | 14 |
| 15 expectSideEffect(test) { |
| 16 c = 0; |
| 17 test(); |
| 18 Expect.isTrue(c == 1); |
| 19 } |
| 20 |
| 15 expectNoSideEffect(test) { | 21 expectNoSideEffect(test) { |
| 16 c = 0; | 22 c = 0; |
| 17 test(); | 23 test(); |
| 18 Expect.isTrue(c == 0); | 24 Expect.isTrue(c == 0); |
| 19 } | 25 } |
| 20 | 26 |
| 21 expectThrowsNotLoaded(test){ | 27 expectThrowsNotLoaded(test){ |
| 22 Expect.throws(test, (e) => e is Error); | 28 Expect.throws(test, (e) => e is Error); |
| 23 } | 29 } |
| 24 | 30 |
| 25 int sideEffect() { | 31 int sideEffect() { |
| 26 c = 1; | 32 c = 1; |
| 27 return 10; | 33 return 10; |
| 28 } | 34 } |
| 29 | 35 |
| 30 void main() { | 36 void main() { |
| 31 expectNoSideEffect(() { | 37 expectSideEffect(() { |
| 32 expectThrowsNotLoaded(() { | 38 expectThrowsNotLoaded(() { |
| 33 lib.foo(sideEffect()); | 39 lib.foo(sideEffect()); |
| 34 }); | 40 }); |
| 35 }); | 41 }); |
| 36 expectNoSideEffect(() { | 42 expectNoSideEffect(() { |
| 37 expectThrowsNotLoaded(() { | 43 expectThrowsNotLoaded(() { |
| 38 lib.C.foo(sideEffect()); | 44 lib.C.foo(sideEffect()); |
| 39 }); | 45 }); |
| 40 }); | 46 }); |
| 41 expectNoSideEffect(() { | 47 expectSideEffect(() { |
| 42 expectThrowsNotLoaded(() { | 48 expectThrowsNotLoaded(() { |
| 43 new lib.C(sideEffect()); | 49 new lib.C(sideEffect()); |
| 44 }); | 50 }); |
| 45 }); | 51 }); |
| 46 expectThrowsNotLoaded(() { | 52 expectThrowsNotLoaded(() { |
| 47 lib.a; | 53 lib.a; |
| 48 }); | 54 }); |
| 49 expectNoSideEffect(() { | 55 expectSideEffect(() { |
| 50 expectThrowsNotLoaded(() { | 56 expectThrowsNotLoaded(() { |
| 51 lib.a = sideEffect(); | 57 lib.a = sideEffect(); |
| 52 }); | 58 }); |
| 53 }); | 59 }); |
| 54 expectThrowsNotLoaded(() { | 60 expectThrowsNotLoaded(() { |
| 55 lib.getter; | 61 lib.getter; |
| 56 }); | 62 }); |
| 57 expectNoSideEffect(() { | 63 expectSideEffect(() { |
| 58 expectThrowsNotLoaded(() { | 64 expectThrowsNotLoaded(() { |
| 59 lib.setter = sideEffect(); | 65 lib.setter = sideEffect(); |
| 60 }); | 66 }); |
| 61 }); | 67 }); |
| 62 expectNoSideEffect(() { | 68 expectNoSideEffect(() { |
| 63 expectThrowsNotLoaded(() { | 69 expectThrowsNotLoaded(() { |
| 64 lib.list[sideEffect()] = sideEffect(); | 70 lib.list[sideEffect()] = sideEffect(); |
| 65 }); | 71 }); |
| 66 }); | 72 }); |
| 67 expectNoSideEffect(() { | 73 expectSideEffect(() { |
| 68 expectThrowsNotLoaded(() { | 74 expectThrowsNotLoaded(() { |
| 69 lib.closure(sideEffect()); | 75 lib.closure(sideEffect()); |
| 70 }); | 76 }); |
| 71 }); | 77 }); |
| 72 } | 78 } |
| OLD | NEW |