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

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

Issue 19097003: Support new malformed types semantics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix unittests. Created 7 years, 4 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
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Unresolved imported symbols are handled differently in production mode and 5 // Unresolved imported symbols are treated as dynamic
6 // check modes. In this test, the function myFunc is malformed, because 6 // In this test, the function myFunc contains malformed types because
7 // lib12.Library13 is not resolved. 7 // lib12.Library13 is not resolved.
8 // In checked mode, the assignment type check throws a run time type error.
9 // In production, no assignment type checks are performed.
10 8
11 library Prefix16NegativeTest.dart; 9 library Prefix16NegativeTest.dart;
12 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
13 import "library12.dart" as lib12; 11 import "library12.dart" as lib12;
14 12
15 typedef lib12.Library13 myFunc(lib12.Library13 param); 13 typedef lib12.Library13 myFunc(lib12.Library13 param);
14 typedef lib12.Library13 myFunc2(lib12.Library13 param, int i);
16 15
17 isCheckedMode() { 16 isCheckedMode() {
18 try { 17 try {
19 var i = 1; 18 var i = 1;
20 String s = i; 19 String s = i;
21 return false; 20 return false;
22 } catch (e) { 21 } catch (e) {
23 return true; 22 return true;
24 } 23 }
25 } 24 }
26 25
27 main() { 26 main() {
28 { 27 {
29 bool got_type_error = false; 28 bool got_type_error = false;
30 try { 29 try {
30 // Malformed myFunc treated as (dynamic) => dynamic.
31 myFunc i = 0; 31 myFunc i = 0;
32 } on TypeError catch (error) { 32 } on TypeError catch (error) {
33 got_type_error = true; 33 got_type_error = true;
34 } 34 }
35 // Type error in checked mode only. 35 // Type error in checked mode only.
36 Expect.isTrue(got_type_error == isCheckedMode()); 36 Expect.isTrue(got_type_error == isCheckedMode());
37 } 37 }
38 { 38 {
39 bool got_type_error = false;
40 try { 39 try {
41 // In production mode, malformed myFunc is mapped to (dynamic) => dynamic. 40 // Malformed myFunc treated as (dynamic) => dynamic.
42 Expect.isTrue(((int x) => x) is myFunc); 41 Expect.isTrue(((int x) => x) is myFunc);
43 } on TypeError catch (error) { 42 } on TypeError catch (error) {
44 got_type_error = true; 43 Expect.fail();
45 } 44 }
46 // Type error in checked mode only. 45 }
47 Expect.isTrue(got_type_error == isCheckedMode()); 46 {
47 try {
48 // Malformed myFunc2 treated as (dynamic,int) => dynamic.
49 Expect.isTrue(((int x, int y) => x) is myFunc2);
50 } on TypeError catch (error) {
51 Expect.fail();
52 }
53 }
54 {
55 try {
56 // Malformed myFunc2 treated as (dynamic,int) => dynamic.
57 Expect.isFalse(((int x, String y) => x) is myFunc2);
58 } on TypeError catch (error) {
59 Expect.fail();
60 }
48 } 61 }
49 } 62 }
OLDNEW
« no previous file with comments | « tests/language/on_catch_malformed_type_test.dart ('k') | tests/language/prefix9_negative_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698