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

Side by Side Diff: tests/language/src/Arithmetic2Test.dart

Issue 9406010: Also allow type-errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Dart test program to test arithmetic operations. 4 // Dart test program to test arithmetic operations.
5 5
6 class A { 6 class A {
7 static foo() => 499; 7 static foo() => 499;
8 } 8 }
9 9
10 bool throwsNoSuchMethod(f) { 10 bool throwsNoSuchMethod(f) {
11 try { 11 try {
12 f(); 12 f();
13 return false; 13 return false;
14 } catch(NoSuchMethodException e) { 14 } catch(NoSuchMethodException e) {
15 return true; 15 return true;
16 } 16 }
17 return false; 17 return false;
18 } 18 }
19 19
20 bool throwsBecauseOfBadArgument(f) { 20 bool throwsBecauseOfBadArgument(f) {
21 try { 21 try {
22 f(); 22 f();
23 return false; 23 return false;
24 } catch(NoSuchMethodException e) { 24 } catch(NoSuchMethodException e) {
25 return true; 25 return true;
26 } catch(IllegalArgumentException e) { 26 } catch(IllegalArgumentException e) {
27 return true; 27 return true;
28 } catch(NullPointerException e) { 28 } catch(NullPointerException e) {
29 return true; 29 return true;
30 } catch (TypeError e) {
31 // In type checked mode.
kasperl 2012/02/15 14:24:22 Maybe you should make sure we're actually running
32 return true;
30 } 33 }
31 return false; 34 return false;
32 } 35 }
33 36
34 numberOpBadSecondArgument(f) { 37 numberOpBadSecondArgument(f) {
35 Expect.isTrue(throwsBecauseOfBadArgument(() => f(true))); 38 Expect.isTrue(throwsBecauseOfBadArgument(() => f(true)));
36 Expect.isTrue(throwsBecauseOfBadArgument(() => f(new A()))); 39 Expect.isTrue(throwsBecauseOfBadArgument(() => f(new A())));
37 Expect.isTrue(throwsBecauseOfBadArgument(() => f("foo"))); 40 Expect.isTrue(throwsBecauseOfBadArgument(() => f("foo")));
38 Expect.isTrue(throwsBecauseOfBadArgument(() => f("5"))); 41 Expect.isTrue(throwsBecauseOfBadArgument(() => f("5")));
39 Expect.isTrue(throwsBecauseOfBadArgument(() => f(() => 499))); 42 Expect.isTrue(throwsBecauseOfBadArgument(() => f(() => 499)));
(...skipping 21 matching lines...) Expand all
61 numberOpBadSecondArgument((x) => 3 - x); 64 numberOpBadSecondArgument((x) => 3 - x);
62 numberOpBadSecondArgument((x) => 3 * x); 65 numberOpBadSecondArgument((x) => 3 * x);
63 numberOpBadSecondArgument((x) => 3 / x); 66 numberOpBadSecondArgument((x) => 3 / x);
64 numberOpBadSecondArgument((x) => 3 ~/ x); 67 numberOpBadSecondArgument((x) => 3 ~/ x);
65 numberOpBadSecondArgument((x) => 3 % x); 68 numberOpBadSecondArgument((x) => 3 % x);
66 badOperations(true); 69 badOperations(true);
67 badOperations(false); 70 badOperations(false);
68 badOperations(() => 499); 71 badOperations(() => 499);
69 badOperations(A.foo); 72 badOperations(A.foo);
70 } 73 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698