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

Side by Side Diff: tests/language_strong/arithmetic2_test.dart

Issue 2990773002: Migrate language/arithmetic2_test ... language/async_await_syntax_test. (Closed)
Patch Set: Update migrated tests and statuses to Dart 2.0. Created 3 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test program to test arithmetic operations.
5
6 import "package:expect/expect.dart";
7
8 class A {
9 static foo() => 499;
10 }
11
12 bool throwsNoSuchMethod(f) {
13 try {
14 f();
15 return false;
16 } on NoSuchMethodError catch (e) {
17 return true;
18 }
19 return false;
20 }
21
22 bool throwsBecauseOfBadArgument(f) {
23 try {
24 f();
25 return false;
26 } on NoSuchMethodError catch (e) {
27 return true;
28 } on ArgumentError catch (e) {
29 return true;
30 } on TypeError catch (e) {
31 // In type checked mode.
32 return true;
33 }
34 return false;
35 }
36
37 numberOpBadSecondArgument(f) {
38 Expect.isTrue(throwsBecauseOfBadArgument(() => f(true)));
39 Expect.isTrue(throwsBecauseOfBadArgument(() => f(new A())));
40 Expect.isTrue(throwsBecauseOfBadArgument(() => f("foo")));
41 Expect.isTrue(throwsBecauseOfBadArgument(() => f("5")));
42 Expect.isTrue(throwsBecauseOfBadArgument(() => f(() => 499)));
43 Expect.isTrue(throwsBecauseOfBadArgument(() => f(null)));
44 Expect.isTrue(throwsBecauseOfBadArgument(() => f(false)));
45 Expect.isTrue(throwsBecauseOfBadArgument(() => f([])));
46 Expect.isTrue(throwsBecauseOfBadArgument(() => f({})));
47 Expect.isTrue(throwsBecauseOfBadArgument(() => f(A.foo)));
48 }
49
50 badOperations(b) {
51 Expect.isTrue(throwsNoSuchMethod(() => b - 3));
52 Expect.isTrue(throwsNoSuchMethod(() => b * 3));
53 Expect.isTrue(throwsNoSuchMethod(() => b ~/ 3));
54 Expect.isTrue(throwsNoSuchMethod(() => b / 3));
55 Expect.isTrue(throwsNoSuchMethod(() => b % 3));
56 Expect.isTrue(throwsNoSuchMethod(() => b + 3));
57 Expect.isTrue(throwsNoSuchMethod(() => b[3]));
58 Expect.isTrue(throwsNoSuchMethod(() => ~b));
59 Expect.isTrue(throwsNoSuchMethod(() => -b));
60 }
61
62 main() {
63 numberOpBadSecondArgument((x) => 3 + x);
64 numberOpBadSecondArgument((x) => 3 - x);
65 numberOpBadSecondArgument((x) => 3 * x);
66 numberOpBadSecondArgument((x) => 3 / x);
67 numberOpBadSecondArgument((x) => 3 ~/ x);
68 numberOpBadSecondArgument((x) => 3 % x);
69 badOperations(true);
70 badOperations(false);
71 badOperations(() => 499);
72 badOperations(A.foo);
73 }
OLDNEW
« no previous file with comments | « tests/language_2/language_2.status ('k') | tests/language_strong/assert_assignable_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698