-
Notifications
You must be signed in to change notification settings - Fork 864
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Processing integers without decimal place is put under feature flag, …
…test for this behaviour is added.
- Loading branch information
1 parent
8574ca4
commit 1ff7bc0
Showing
9 changed files
with
96 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
js> m = new java.util.LinkedHashMap(); m.put("a",1); m.put("b",2); m | ||
{a=1, b=2} | ||
js> for (i in Iterator(m.values())) print(i) | ||
1 | ||
2 | ||
js> for (i in Iterator(m.values().iterator())) print(i) | ||
1 | ||
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
testsrc/org/mozilla/javascript/tests/DoctestFeature18EnabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.mozilla.javascript.tests; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
import org.mozilla.javascript.Context; | ||
import org.mozilla.javascript.ContextFactory; | ||
import org.mozilla.javascript.tools.shell.Global; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
@RunWith(Parameterized.class) | ||
public class DoctestFeature18EnabledTest extends DoctestsTest { | ||
public DoctestFeature18EnabledTest(String name, String source, int optimizationLevel) { | ||
super(name, source, optimizationLevel); | ||
} | ||
|
||
@Parameters(name = "{0}") | ||
public static Collection<Object[]> singleDoctest() throws IOException { | ||
List<Object[]> result = new ArrayList<Object[]>(); | ||
File f = new File(DoctestsTest.baseDirectory, "feature18enabled.doctest"); | ||
String contents = DoctestsTest.loadFile(f); | ||
result.add(new Object[]{f.getName(), contents, -1}); | ||
return result; | ||
} | ||
|
||
@Test | ||
public void runDoctest() { | ||
ContextFactory contextFactory = new ContextFactory() { | ||
@Override | ||
protected boolean hasFeature(Context cx, int featureIndex) { | ||
if (featureIndex == Context.FEATURE_INTEGER_WITHOUT_DECIMAL_PLACE) { | ||
return true; | ||
} | ||
return super.hasFeature(cx, featureIndex); | ||
} | ||
}; | ||
Context context = contextFactory.enterContext(); | ||
try { | ||
context.setOptimizationLevel(optimizationLevel); | ||
Global global = new Global(context); | ||
int testsPassed = global.runDoctest(context, global, source, name, 1); | ||
assertTrue(testsPassed > 0); | ||
} finally { | ||
Context.exit(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters