20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package jdk.nashorn.api.tree.test; 26 27 import java.io.File; 28 import java.io.IOException; 29 import java.nio.charset.Charset; 30 import java.nio.charset.StandardCharsets; 31 import java.nio.file.Files; 32 import jdk.nashorn.api.tree.Parser; 33 import jdk.nashorn.api.tree.SimpleTreeVisitorES5_1; 34 import jdk.nashorn.api.tree.Tree; 35 import org.testng.Assert; 36 import org.testng.annotations.Test; 37 38 /** 39 * Test for nashorn Parser API (jdk.nashorn.api.tree.*) 40 */ 41 public class ParseAPITest { 42 43 private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("parserapitest.verbose")); 44 private static final boolean TEST262 = Boolean.valueOf(System.getProperty("parserapitest.test262")); 45 46 private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir"); 47 private static final String TEST_MAPTESTS_DIR = System.getProperty("test.maptests.dir"); 48 private static final String TEST_SANDBOX_DIR = System.getProperty("test.sandbox.dir"); 49 private static final String TEST_TRUSTED_DIR = System.getProperty("test.trusted.dir"); 50 private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir"); 51 52 interface TestFilter { 53 public boolean exclude(File file, String content); 54 } 55 56 private void log(String msg) { 57 org.testng.Reporter.log(msg, true); 58 } 59 60 private static final String[] options = new String[] { 61 "-scripting", "--const-as-var" 62 }; 63 64 @Test 65 public void parseAllTests() { 66 if (TEST262) { 67 parseTestSet(TEST262_SUITE_DIR, new TestFilter() { 68 @Override 69 public boolean exclude(final File file, final String content) { 70 return content.contains("@negative"); | 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package jdk.nashorn.api.tree.test; 26 27 import java.io.File; 28 import java.io.IOException; 29 import java.nio.charset.Charset; 30 import java.nio.charset.StandardCharsets; 31 import java.nio.file.Files; 32 import jdk.nashorn.api.tree.Parser; 33 import jdk.nashorn.api.tree.SimpleTreeVisitorES5_1; 34 import jdk.nashorn.api.tree.Tree; 35 import org.testng.Assert; 36 import org.testng.annotations.Test; 37 38 /** 39 * Test for nashorn Parser API (jdk.nashorn.api.tree.*) 40 * 41 * @test 42 * @run testng jdk.nashorn.api.tree.test.ParseAPITest 43 */ 44 public class ParseAPITest { 45 46 private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("parserapitest.verbose")); 47 private static final boolean TEST262 = Boolean.valueOf(System.getProperty("parserapitest.test262")); 48 49 private static String TEST_BASIC_DIR = System.getProperty("test.basic.dir"); 50 private static String TEST_MAPTESTS_DIR = System.getProperty("test.maptests.dir"); 51 private static String TEST_SANDBOX_DIR = System.getProperty("test.sandbox.dir"); 52 private static String TEST_TRUSTED_DIR = System.getProperty("test.trusted.dir"); 53 private static String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir"); 54 55 static { 56 String testSrc = System.getProperty("test.src"); 57 if (testSrc != null) { 58 String testScriptDir = testSrc + "/../../../../../../script/"; 59 TEST_BASIC_DIR = testScriptDir + "basic"; 60 TEST_MAPTESTS_DIR = testScriptDir + "maptests"; 61 TEST_SANDBOX_DIR = testScriptDir + "sandbox"; 62 TEST_TRUSTED_DIR = testScriptDir + "trusted"; 63 TEST262_SUITE_DIR = testScriptDir + "external/test262/test/suite"; 64 } else { 65 TEST_BASIC_DIR = System.getProperty("test.basic.dir"); 66 TEST_MAPTESTS_DIR = System.getProperty("test.maptests.dir"); 67 TEST_SANDBOX_DIR = System.getProperty("test.sandbox.dir"); 68 TEST_TRUSTED_DIR = System.getProperty("test.trusted.dir"); 69 TEST262_SUITE_DIR = System.getProperty("test262.suite.dir"); 70 } 71 } 72 73 interface TestFilter { 74 public boolean exclude(File file, String content); 75 } 76 77 private void log(String msg) { 78 org.testng.Reporter.log(msg, true); 79 } 80 81 private static final String[] options = new String[] { 82 "-scripting", "--const-as-var" 83 }; 84 85 @Test 86 public void parseAllTests() { 87 if (TEST262) { 88 parseTestSet(TEST262_SUITE_DIR, new TestFilter() { 89 @Override 90 public boolean exclude(final File file, final String content) { 91 return content.contains("@negative"); |