Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 46079 Details for
Bug 150074
[compiler] init part of for each loop with empty body is not executed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Regression tests
patch_150074_test.txt (text/plain), 4.84 KB, created by
Olivier Thomann
on 2006-07-11 10:39:02 EDT
(
hide
)
Description:
Regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-07-11 10:39:02 EDT
Size:
4.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java,v >retrieving revision 1.29 >diff -u -r1.29 ForeachStatementTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java 29 Mar 2006 03:50:22 -0000 1.29 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java 11 Jul 2006 14:39:57 -0000 >@@ -38,11 +38,11 @@ > } > // Static initializer to specify tests subset using TESTS_* static variables > // All specified tests which do not belong to the class are skipped... >-//static { >+static { > // TESTS_NAMES = new String[] { "test000" }; >-// TESTS_NUMBERS = new int[] { 31 }; >+// TESTS_NUMBERS = new int[] { 40 }; > // TESTS_RANGE = new int[] { 34, 38 }; >-//} >+} > public static Test suite() { > return buildComparableTestSuite(testClass()); > } >@@ -2106,6 +2106,110 @@ > assertTrue(false); > } > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150074 >+public void test039() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "import java.util.HashSet;\n" + >+ "import java.util.Set;\n" + >+ "import java.util.Iterator;\n" + >+ "\n" + >+ "public class X {\n" + >+ "\n" + >+ " public static void main(String[] args) {\n" + >+ " for (Object o : initForEach()) {\n" + >+ " }\n" + >+ " }\n" + >+ "\n" + >+ " static class MyIterator<T> implements Iterator<T> {\n" + >+ " Iterator<T> iterator;\n" + >+ " \n" + >+ " MyIterator(Iterator<T> it) {\n" + >+ " this.iterator = it;\n" + >+ " }\n" + >+ " public boolean hasNext() {\n" + >+ " System.out.println(\"hasNext\");\n" + >+ " return this.iterator.hasNext();\n" + >+ " } \n" + >+ " public T next() {\n" + >+ " System.out.println(\"next\");\n" + >+ " return this.iterator.next();\n" + >+ " }\n" + >+ " public void remove() {\n" + >+ " System.out.println(\"remove\");\n" + >+ " this.iterator.remove();\n" + >+ " }\n" + >+ " }\n" + >+ " \n" + >+ " static Set<Object> initForEach() {\n" + >+ " System.out.println(\"initForEach\");\n" + >+ " HashSet<Object> set = new HashSet<Object>() {\n" + >+ " private static final long serialVersionUID = 1L;\n" + >+ " public Iterator<Object> iterator() {\n" + >+ " System.out.println(\"iterator\");\n" + >+ " return new MyIterator<Object>(super.iterator());\n" + >+ " }\n" + >+ " };\n" + >+ " for (int i = 0; i < 3; i++) set.add(i);\n" + >+ " return set;\n" + >+ " }\n" + >+ "}", >+ }, >+ "initForEach\n" + >+ "iterator\n" + >+ "hasNext\n" + >+ "next\n" + >+ "hasNext\n" + >+ "next\n" + >+ "hasNext\n" + >+ "next\n" + >+ "hasNext"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150074 >+public void test040() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " for (int i : initForEach()) {\n" + >+ " }\n" + >+ " }\n" + >+ " static int[] initForEach() {\n" + >+ " System.out.println(\"initForEach\");\n" + >+ " return new int[] {1, 2, 3, 4};\n" + >+ " }\n" + >+ "}", >+ }, >+ "initForEach"); >+ >+ String expectedOutput = >+ " // Method descriptor #15 ([Ljava/lang/String;)V\n" + >+ " // Stack: 1, Locals: 1\n" + >+ " public static void main(java.lang.String[] args);\n" + >+ " 0 invokestatic X.initForEach() : int[] [16]\n" + >+ " 3 pop\n" + >+ " 4 return\n"; >+ >+ try { >+ File f = new File(OUTPUT_DIR + File.separator + "X.class"); >+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); >+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); >+ int index = result.indexOf(expectedOutput); >+ if (index == -1 || expectedOutput.length() == 0) { >+ System.out.println(Util.displayString(result, 3)); >+ } >+ if (index == -1) { >+ assertEquals("Wrong contents", expectedOutput, result); >+ } >+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) { >+ assertTrue(false); >+ } catch (IOException e) { >+ assertTrue(false); >+ } >+} > public static Class testClass() { > return ForeachStatementTest.class; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 150074
:
46069
|
46070
|
46072
|
46078
|
46079
|
46180
|
46181