Skip to content

Instantly share code, notes, and snippets.

@brunoborges
Created May 30, 2015 10:36
Show Gist options
  • Save brunoborges/c0ae1e2b9dfd7f67b3ee to your computer and use it in GitHub Desktop.
Save brunoborges/c0ae1e2b9dfd7f67b3ee to your computer and use it in GitHub Desktop.
java.net.URL shouldn't be used to represent URLs
#!/usr/bin/env jjs
function runTest() {
var URL = Packages.java.net.URL;
var LinkedHashSet = Packages.java.util.LinkedHashSet;
set = new LinkedHashSet();
set.add(new URL("http://Square.GitHub.io/"));
set.add(new URL("http://square.github.io:80/"));
set.add(new URL("http://google.github.io/"));
size = set.size();
if (size === 2) {
print("============= CORRECT ===========");
} else {
print("Awkward... ");
}
}
function callExternalNashorn() {
for (i = 0; i < 100; i++) {
script = __FILE__;
$EXEC('jjs -Dsanity=true -scripting ' + script);
print($OUT);
}
}
if (java.lang.System.getProperty("sanity") === "true") {
runTest();
} else {
callExternalNashorn();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment