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

Unified Diff: test/checker/checker_test.dart

Issue 1147143007: fixes #206, add checking for unary ops (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: merged Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/opassign.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/checker/checker_test.dart
diff --git a/test/checker/checker_test.dart b/test/checker/checker_test.dart
index 40c2e0fe9a2f6dcb5c62c27ca2481702aad4913f..e587876f8a7f311d94ca9ba19965b34d8842f715 100644
--- a/test/checker/checker_test.dart
+++ b/test/checker/checker_test.dart
@@ -39,11 +39,50 @@ void main() {
}
}
void main() {
+ Object obj = 42;
+ dynamic dyn = 42;
+ int i = 42;
+
+ // Check the boolean conversion of the condition.
+ print((/*severe:StaticTypeError*/i) ? false : true);
+ print((/*warning:DownCastImplicit*/obj) ? false : true);
+ print((/*info:DynamicCast*/dyn) ? false : true);
}
'''
});
});
+ test('if/for/do/while statements use boolean conversion', () => testChecker({
+ '/main.dart': '''
+ main() {
+ dynamic d = 42;
+ Object obj = 42;
+ int i = 42;
+ bool b = false;
+
+ if (b) {}
+ if (/*info:DynamicCast*/dyn) {}
+ if (/*warning:DownCastImplicit*/obj) {}
+ if (/*severe:StaticTypeError*/i) {}
+
+ while (b) {}
+ while (/*info:DynamicCast*/dyn) {}
+ while (/*warning:DownCastImplicit*/obj) {}
+ while (/*severe:StaticTypeError*/i) {}
+
+ do {} while (b);
+ do {} while (/*info:DynamicCast*/dyn);
+ do {} while (/*warning:DownCastImplicit*/obj);
+ do {} while (/*severe:StaticTypeError*/i);
+
+ for (;b;) {}
+ for (;/*info:DynamicCast*/dyn;) {}
+ for (;/*warning:DownCastImplicit*/obj;) {}
+ for (;/*severe:StaticTypeError*/i;) {}
+ }
+ '''
+ }));
+
test('dynamic invocation', () {
testChecker({
'/main.dart': '''
@@ -1924,6 +1963,42 @@ void main() {
}, inferFromOverrides: true);
});
+ test('unary operators', () => testChecker({
+ '/main.dart': '''
+ class A {
+ A operator ~() {}
+ A operator +(int x) {}
+ A operator -(int x) {}
+ A operator -() {}
+ }
+
+ foo() => new A();
+
+ test() {
+ A a = new A();
+ var c = foo();
+
+ ~a;
+ (/*info:DynamicInvoke*/~d);
+
+ !/*severe:StaticTypeError*/a;
+ !/*info:DynamicCast*/d;
+
+ -a;
+ (/*info:DynamicInvoke*/-d);
+
+ ++a;
+ --a;
+ (/*info:DynamicInvoke*/++d);
+ (/*info:DynamicInvoke*/--d);
+
+ a++;
+ a--;
+ (/*info:DynamicInvoke*/d++);
+ (/*info:DynamicInvoke*/d--);
+ }'''
+ }));
+
test('binary and index operators', () {
testChecker({
'/main.dart': '''
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | test/codegen/expect/opassign.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698