Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: tests/language/deferred_not_loaded_check_test.dart

Issue 232563006: Insert checks before deferred calls and accesses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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())}");
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698