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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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 // Testing optimized 'is' tests. 4 // Testing optimized 'is' tests.
5 // VMOptions=--optimization-counter-threshold=5 --no-use-osr --no-background-com pilation 5 // VMOptions=--optimization-counter-threshold=5 --no-use-osr --no-background-com pilation
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9
10 bool isInt(x) => x is int; 9 bool isInt(x) => x is int;
11 10
12
13 int isIntRes(x) { 11 int isIntRes(x) {
14 if (x is int) { 12 if (x is int) {
15 return 1; 13 return 1;
16 } else { 14 } else {
17 return 0; 15 return 0;
18 } 16 }
19 } 17 }
20 18
21
22 int isNotIntRes(x) { 19 int isNotIntRes(x) {
23 if (x is! int) { 20 if (x is! int) {
24 return 1; 21 return 1;
25 } else { 22 } else {
26 return 0; 23 return 0;
27 } 24 }
28 } 25 }
29 26
30
31 int isIfThenElseIntRes(x) { 27 int isIfThenElseIntRes(x) {
32 return x is int ? 1 : 0; 28 return x is int ? 1 : 0;
33 } 29 }
34 30
35
36
37 bool isString(x) => x is String; 31 bool isString(x) => x is String;
38 32
39
40 int isStringRes(x) { 33 int isStringRes(x) {
41 if (x is String) { 34 if (x is String) {
42 return 1; 35 return 1;
43 } else { 36 } else {
44 return 0; 37 return 0;
45 } 38 }
46 } 39 }
47 40
48
49 int isNotStringRes(x) { 41 int isNotStringRes(x) {
50 if (x is! String) { 42 if (x is! String) {
51 return 1; 43 return 1;
52 } else { 44 } else {
53 return 0; 45 return 0;
54 } 46 }
55 } 47 }
56 48
57
58 main() { 49 main() {
59 for (int i = 0; i < 20; i++) { 50 for (int i = 0; i < 20; i++) {
60 Expect.isFalse(isInt(3.2)); 51 Expect.isFalse(isInt(3.2));
61 Expect.isTrue(isInt(3)); 52 Expect.isTrue(isInt(3));
62 Expect.isTrue(isInt(17179869184)); // Mint on ia32. 53 Expect.isTrue(isInt(17179869184)); // Mint on ia32.
63 Expect.isFalse(isString(2.0)); 54 Expect.isFalse(isString(2.0));
64 Expect.isTrue(isString("Morgan")); 55 Expect.isTrue(isString("Morgan"));
65 } 56 }
66 // No deoptimization of isInt possible since all types are known by the compil er 57 // No deoptimization of isInt possible since all types are known by the compil er
67 58
68 Expect.isFalse(isString(true)); 59 Expect.isFalse(isString(true));
69 for (int i = 0; i < 20; i++) { 60 for (int i = 0; i < 20; i++) {
70 Expect.isFalse(isInt(3.2)); 61 Expect.isFalse(isInt(3.2));
71 Expect.isTrue(isInt(3)); 62 Expect.isTrue(isInt(3));
72 Expect.isTrue(isInt(17179869184)); // Mint on ia32. 63 Expect.isTrue(isInt(17179869184)); // Mint on ia32.
73 Expect.isFalse(isInt("hu")); 64 Expect.isFalse(isInt("hu"));
74 Expect.isFalse(isString(2.0)); 65 Expect.isFalse(isString(2.0));
75 Expect.isTrue(isString("Morgan")); 66 Expect.isTrue(isString("Morgan"));
76 Expect.isFalse(isString(true)); 67 Expect.isFalse(isString(true));
77 } 68 }
78 69
79 for (int i = 0; i < 20; i++) { 70 for (int i = 0; i < 20; i++) {
80 Expect.equals(0, isIntRes(3.2)); 71 Expect.equals(0, isIntRes(3.2));
81 Expect.equals(1, isIntRes(3)); 72 Expect.equals(1, isIntRes(3));
82 Expect.equals(0, isIntRes("hi")); 73 Expect.equals(0, isIntRes("hi"));
(...skipping 17 matching lines...) Expand all
100 Expect.equals(1, isNotIntRes(null)); 91 Expect.equals(1, isNotIntRes(null));
101 for (int i = 0; i < 20; i++) { 92 for (int i = 0; i < 20; i++) {
102 Expect.equals(0, isStringRes(3.2)); 93 Expect.equals(0, isStringRes(3.2));
103 Expect.equals(1, isStringRes("Lotus")); 94 Expect.equals(1, isStringRes("Lotus"));
104 Expect.equals(0, isStringRes(null)); 95 Expect.equals(0, isStringRes(null));
105 96
106 Expect.equals(1, isNotStringRes(3.2)); 97 Expect.equals(1, isNotStringRes(3.2));
107 Expect.equals(0, isNotStringRes("Lotus")); 98 Expect.equals(0, isNotStringRes("Lotus"));
108 Expect.equals(1, isNotStringRes(null)); 99 Expect.equals(1, isNotStringRes(null));
109 } 100 }
110 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698