### Question:
ScriptDocument { public static ScriptDocument parse(String aSource, String aName) { ScriptDocument doc = new ScriptDocument(); doc.readScriptModules(aSource, aName); return doc; } protected  ScriptDocument(); static ScriptDocument parse(String aSource, String aName); Map<String, ModuleDocument> getModules();  }### Answer:
@Test public void annotatedGlobalAndAmd1ArgDefineTest() { String jsText = "" + "function GlobalModule1(){" + " var self = this;" + " \n" + " self.a = {};" + " this.m = function(){};" + "}" + "function GlobalModule2(){" + " var self = this;" + " \n" + " self.a = {};" + " this.m = function(){};" + "}" + "define('AmdDefineTest1', [], function(){" + " function module_constructor(){" + " var self = this;" + " \n" + " self.a = {};" + " this.m = function(){};" + " }" + " return module_constructor;" + "});" + "define('AmdDefineTest2', [], function(){" + " function module_constructor(){" + " var self = this;" + " \n" + " self.a = {};" + " this.m = function(){};" + " }" + " return module_constructor;" + "});" + "define(function(){" + " function module_constructor(){" + " var self = this;" + " \n" + " self.a = {};" + " this.m = function(){};" + " }" + " return module_constructor;" + "});" + ""; ScriptDocument doc = ScriptDocument.parse(jsText, "AmdDefineTestDefault"); verifyModulesDocuments(doc); }
@Test public void globalAndAmd3ArgDefineTest() { String jsText = "" + "function GlobalModule1(){" + " var self = this;" + " \n" + " self.a = {};" + " this.m = function(){};" + "}" + "function GlobalModule2(){" + " var self = this;" + " \n" + " self.a = {};" + " this.m = function(){};" + "}" + "define('AmdDefineTest1',[], function(){" + " function module_constructor(){" + " var self = this;" + " \n" + " this.a = {};" + " self.m = function(){};" + " }" + " return module_constructor;" + "});" + "define([], function(){" + " function module_constructor(){" + " var self = this;" + " \n" + " this.a = {};" + " self.m = function(){};" + " }" + " return module_constructor;" + "});" + "define('AmdDefineTest2', [], function(){" + " function module_constructor(){" + " var self = this;" + " \n" + " this.a = {};" + " self.m = function(){};" + " }" + " return module_constructor;" + "});" + ""; ScriptDocument doc = ScriptDocument.parse(jsText, "AmdDefineTestDefault"); verifyModulesDocuments(doc); }
@Test public void jQueryLargeFileMinified() throws IOException { URL resource = ScriptDocumentTest.class.getClassLoader().getResource("com/eas/client/cache/reg-exp-literal.min-jquery.js"); ScriptDocument.parse(readUrl(resource), "jquery-large-min"); }
@Test public void jQueryLargeFile() throws IOException { URL resource = ScriptDocumentTest.class.getClassLoader().getResource("com/eas/client/cache/reg-exp-literal-jquery.js"); ScriptDocument.parse(readUrl(resource), "leaflet-large"); }
@Test public void leafletLargeFile() throws IOException { URL resource = ScriptDocumentTest.class.getClassLoader().getResource("com/eas/client/cache/numeric-literal-leaflet.js"); ScriptDocument.parse(readUrl(resource), "jquery-large"); }