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

Side by Side Diff: tests/compiler/dart2js_native/type_error_decode_test.dart

Issue 2379173002: Add native_testing library to mock @Native classes (Closed)
Patch Set: xxx Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library test.type_error_decode_test; 5 library test.type_error_decode_test;
6 6
7 import 'package:expect/expect.dart'; 7 import 'native_testing.dart';
8 8 import 'dart:_js_helper' show NullError, JsNoSuchMethodError;
9 import 'dart:_js_helper';
10 9
11 class Foo { 10 class Foo {
12 var field; 11 var field;
13 } 12 }
14 13
15 isNullError(e, trace) { 14 isNullError(e, trace) {
16 print('$e\nTrace: $trace'); 15 print('$e\nTrace: $trace');
17 return e is NullError; 16 return e is NullError;
18 } 17 }
19 18
(...skipping 14 matching lines...) Expand all
34 throw 'No exception thrown'; 33 throw 'No exception thrown';
35 } 34 }
36 35
37 main() { 36 main() {
38 var x = null; 37 var x = null;
39 var z = new Object(); 38 var z = new Object();
40 var v = new List(1)[0]; 39 var v = new List(1)[0];
41 var s = "Cannot call method 'foo' of null"; 40 var s = "Cannot call method 'foo' of null";
42 var nul = null; 41 var nul = null;
43 var f = new Foo(); 42 var f = new Foo();
44 // This should foil code analysis so the variables aren't inlined below. 43
45 [].forEach((y) => f.field = nul = s = x = z = v = y);
46 expectThrows(() => x.fisk(), isNullError); 44 expectThrows(() => x.fisk(), isNullError);
47 expectThrows(() => v.fisk(), isNullError); 45 expectThrows(() => v.fisk(), isNullError);
48 expectThrows(() => z.fisk(), isJsNoSuchMethodError); 46 expectThrows(() => z.fisk(), isJsNoSuchMethodError);
49 expectThrows(() => s.fisk(), isJsNoSuchMethodError); 47 expectThrows(() => s.fisk(), isJsNoSuchMethodError);
50 expectThrows(() => null(), isNullError); 48 expectThrows(() => null(), isNullError);
51 expectThrows(() => f.field(), isNullError); 49 expectThrows(() => f.field(), isNullError);
50
51 expectThrows(() => confuse(x).fisk(), isNullError);
52 expectThrows(() => confuse(v).fisk(), isNullError);
53 expectThrows(() => confuse(z).fisk(), isJsNoSuchMethodError);
54 expectThrows(() => confuse(s).fisk(), isJsNoSuchMethodError);
55 expectThrows(() => confuse(null)(), isNullError);
56 expectThrows(() => confuse(f).field(), isNullError);
57 expectThrows(() => confuse(f.field)(), isNullError);
52 } 58 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/super_property_test.dart ('k') | tests/compiler/dart2js_native/undefined_bailout_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698