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

Unified Diff: editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SyntaxTranslatorTest.java

Issue 221483002: Fix for translation of \!= to \!identical(), but use == and \!= for Enum. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
Index: editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SyntaxTranslatorTest.java
diff --git a/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SyntaxTranslatorTest.java b/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SyntaxTranslatorTest.java
index 4996b5b286dfda88486e85db8e644061fc99ddbd..edaf3dbd8e38f25f4d63e01d0cd824ca0197b2e3 100644
--- a/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SyntaxTranslatorTest.java
+++ b/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SyntaxTranslatorTest.java
@@ -332,17 +332,45 @@ public class SyntaxTranslatorTest extends AbstractSemanticTest {
parseJava(
"// filler filler filler filler filler filler filler filler filler filler",
"public class A {",
- " boolean testA(Object a, Object b) {",
+ " boolean testObject(Object a, Object b) {",
" return a == b;",
" }",
- " boolean testB(Object p) {",
- " return p == null || p == 1 || p == 2L || p == 3.0f || p == 4.0d;",
+ " boolean testNull(Object p) {",
+ " return p == null;",
+ " }",
+ " boolean testBool(Object p) {",
+ " return p == true;",
+ " }",
+ " boolean testChar(Object p) {",
+ " return p == '0';",
+ " }",
+ " boolean testByte(Object p) {",
+ " return p == (byte) 1;",
+ " }",
+ " boolean testInt(Object p) {",
+ " return p == 2;",
+ " }",
+ " boolean testLong(Object p) {",
+ " return p == 3L;",
+ " }",
+ " boolean testFloat(Object p) {",
+ " return p == 4.0f;",
+ " }",
+ " boolean testDouble(Object p) {",
+ " return p == 5.0d;",
" }",
"}");
assertDartSource(
"class A {",
- " bool testA(Object a, Object b) => identical(a, b);",
- " bool testB(Object p) => p == null || p == 1 || p == 2 || p == 3.0 || p == 4.0;",
+ " bool testObject(Object a, Object b) => identical(a, b);",
+ " bool testNull(Object p) => p == null;",
+ " bool testBool(Object p) => p == true;",
+ " bool testChar(Object p) => p == 0x30;",
+ " bool testByte(Object p) => p == 1;",
+ " bool testInt(Object p) => p == 2;",
+ " bool testLong(Object p) => p == 3;",
+ " bool testFloat(Object p) => p == 4.0;",
+ " bool testDouble(Object p) => p == 5.0;",
"}");
}
@@ -364,6 +392,24 @@ public class SyntaxTranslatorTest extends AbstractSemanticTest {
"}");
}
+ public void test_expression_notEquals() throws Exception {
+ parseJava(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "public class A {",
+ " boolean testA(Object a, Object b) {",
+ " return a != b;",
+ " }",
+ " boolean testB(Object p) {",
+ " return p != null || p != 1 || p != 2L || p != 3.0f || p != 4.0d;",
+ " }",
+ "}");
+ assertDartSource(
+ "class A {",
+ " bool testA(Object a, Object b) => !identical(a, b);",
+ " bool testB(Object p) => p != null || p != 1 || p != 2 || p != 3.0 || p != 4.0;",
+ "}");
+ }
+
public void test_expressionArrayAccess() throws Exception {
parseJava(
"// filler filler filler filler filler filler filler filler filler filler",
@@ -498,6 +544,28 @@ public class SyntaxTranslatorTest extends AbstractSemanticTest {
"}");
}
+ public void test_expressionCast_toByte() throws Exception {
+ parseJava(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "public class Test {",
+ " void main(Object p) {",
+ " print((byte) p);",
+ " print((byte) 2);",
+ " print((byte) 256);",
+ " print((byte) 257);",
+ " }",
+ "}");
+ assertDartSource(//
+ "class Test {",
+ " void main(Object p) {",
+ " print(toByte(p));",
+ " print(2);",
+ " print(0);",
+ " print(1);",
+ " }",
+ "}");
+ }
+
public void test_expressionClassInstanceCreation() throws Exception {
parseJava(
"// filler filler filler filler filler filler filler filler filler filler",

Powered by Google App Engine
This is Rietveld 408576698