UNPKG

@seanox/aspect-js

Version:

full stack JavaScript framework for SPAs incl. reactivity rendering, mvc / mvvm, models, expression language, datasource, routing, paths, unit test and some more

285 lines (265 loc) 11.5 kB
<!DOCTYPE HTML> <html> <head> <meta charset="ISO-8859-1"> <title>Seanox aspect-js test environment</title> <style> body { font-family: monospace; white-space: pre; } </style> <script src="aspect-js.js"></script> <script type="text/javascript"> Test.activate(); Test.create({test() { Assert.assertNotEquals("undefined", typeof Namespace); Assert.assertEquals("object", typeof Namespace); Assert.assertEquals("function", typeof Namespace.use); }}); Test.create({test() { Assert.assertEquals(window, Namespace.use()); }}); Test.create({expected:TypeError, test() { Namespace.use(null); }}); Test.create({expected:TypeError, test() { Namespace.use(false); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use(" "); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("?"); }}); Test.create({test() { Assert.assertEquals("undefined", typeof x0001); Assert.assertEquals("object", typeof Namespace.use("x0001")); Assert.assertEquals("object", typeof Namespace.use("x0001.a")); Assert.assertEquals("object", typeof Namespace.use("x0001.a.b.c.d")); Assert.assertEquals("object", typeof x0001); Assert.assertEquals("object", typeof x0001.a); Assert.assertEquals("object", typeof x0001.a.b); Assert.assertEquals("object", typeof x0001.a.b.c); Assert.assertEquals("object", typeof x0001.a.b.c.d); }}); Test.create({test() { Assert.assertEquals("undefined", typeof x0002); Assert.assertEquals("object", typeof Namespace.use("x0002")); Assert.assertEquals("object", typeof Namespace.use("x0002.a")); Assert.assertEquals("object", typeof Namespace.use("x0002.a.b.c.d")); Assert.assertEquals("object", typeof x0002); Assert.assertEquals("object", typeof x0002.a); Assert.assertEquals("object", typeof x0002.a.b); Assert.assertEquals("object", typeof x0002.a.b.c); Assert.assertEquals("object", typeof x0002.a.b.c.d); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("x0002/a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("x0002/a/b/c/d"); }}); Test.create({test() { Assert.assertEquals("undefined", typeof x0003); Assert.assertEquals("object", typeof Namespace.use("x0003")); Assert.assertEquals("object", typeof Namespace.use("x0003.a")); Assert.assertEquals("object", typeof Namespace.use("x0003.a.b.c.d")); Assert.assertEquals("object", typeof x0003); Assert.assertEquals("object", typeof x0003.a); Assert.assertEquals("object", typeof x0003.a.b); Assert.assertEquals("object", typeof x0003.a.b.c); Assert.assertEquals("object", typeof x0003.a.b.c.d); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("x0003\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("x0003\\a\\b\\c\\d"); }}); Test.create({expected:/Invalid namespace at level 4/, test() { Namespace.use("x0001.a.b. .d"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("x0002/a/b/?/d"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("x0003\\a\\b\\*\\d"); }}); Test.create({expected:/Invalid namespace at level 2/, test() { Namespace.use("x0004.a/b.c.d"); }}); Test.create({expected:/Invalid namespace at level 3/, test() { Namespace.use("x0004.a.b\\c.d"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("\\x0005\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("\\\\x0005\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("/x0005/a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("////x0005/a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("\\\\x0005\\\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("//x0005//a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use(".x0005.a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.use("..x0005.a"); }}); Namespace.create("object1", { a: null, b: "", c: 123, d: new Date(), e: {}, f() {} }); Test.create({test() { Namespace.use("object1"); Namespace.use("object1.a"); Namespace.use("object1.d"); Namespace.use("object1.e"); }}); Test.create({expected:/Invalid namespace type at level 2: function/, test() { Namespace.use("object1.f"); }}); Test.create({expected:/Invalid namespace type at level 2: string/, test() { Namespace.use("object1.b"); }}); Test.create({expected:/Invalid namespace type at level 2: number/, test() { Namespace.use("object1.c"); }}); Test.create({test() { Namespace.use("_"); Namespace.use("__"); Namespace.use("_a"); Namespace.use("__a"); Namespace.use("_1"); Namespace.use("__1"); }}); Test.create({expected:/Invalid namespace at level 1: 0/, test() { Namespace.use("0"); }}); Test.create({test() { // The example looks strange, but it is correct. // In JavaScript, objects can be created in this way properties // that have a number as a name without it being an array. Assert.assertEquals("object", typeof Namespace.use("x0")); Assert.assertEquals("object", typeof Namespace.use(x0, "0")); Assert.assertEquals("object", typeof Namespace.use("x0")); }}); Test.create({test() { Assert.assertEquals("object", typeof Namespace.use("xx0.0")); Assert.assertTrue(Array.isArray(xx0)); Assert.assertEquals(1, xx0.length); }}); const x2x1 = {}; window["x2x1"] = {}; Test.create({test() { Assert.assertNotEquals(x2x1, window["x2x1"]); }}); // Another feature of JavaScript in the browser. // There are basically two global namespaces: One is created by the tag // script and there is window -- in both, objects with the same name can // be created with different instances. const x2x2 = {}; Test.create({test() { const x = Namespace.use("x2x2"); Assert.assertEquals(x2x2, x); }}); // The test is similar to x0.0, but here using is called in such a way // that it is recognizable for the method that a will be an array. Test.create({test() { Assert.assertEquals("undefined", typeof a); Assert.assertEquals("object", typeof Namespace.use("a.0")); Assert.assertEquals("object", typeof Namespace.use(a, "0")); Assert.assertTrue(Array.isArray(a)); }}); Test.create({test() { Assert.assertEquals("undefined", typeof b); Assert.assertEquals("object", typeof Namespace.use("b.0b")); Assert.assertEquals("object", typeof Namespace.use(b, "0b")); Assert.assertFalse(Array.isArray(b)); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("x0003\\a"); }}); Test.create({expected:/Invalid namespace at level 4/, test() { Namespace.exists("x0001.a.b. .d"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("x0002/a/b/?/d"); }}); Test.create({expected:/Invalid namespace at level 3/, test() { Namespace.exists("x0004.a.b\\c.d"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("\\x0005\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("/x0005/a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("////x0005/a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("\\\\x0005\\\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("//x0005//a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists(".x0005.a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.exists("..x0005.a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("x0003\\a"); }}); Test.create({expected:/Invalid namespace at level 4/, test() { Namespace.lookup("x0001.a.b. .d"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("x0002/a/b/?/d"); }}); Test.create({expected:/Invalid namespace at level 3/, test() { Namespace.lookup("x0004.a.b\\c.d"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("\\x0005\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("/x0005/a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("////x0005/a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("\\\\x0005\\\\a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("//x0005//a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup(".x0005.a"); }}); Test.create({expected:/Invalid namespace at level 1/, test() { Namespace.lookup("..x0005.a"); }}); Test.start({auto:true}); </script> </head> <body> </body> </html>