removing logs, moving parse function to bottom
This commit is contained in:
@@ -39,10 +39,13 @@ window.testSuites.push( class testObservedObject {
|
||||
}
|
||||
}
|
||||
|
||||
// throw some sort of warning if a global OO is accessed without "this"
|
||||
|
||||
NotExtensible() {
|
||||
return "not done"
|
||||
}
|
||||
|
||||
|
||||
// MustInitAllFields() {
|
||||
// class Form extends ObservedObject {
|
||||
// id
|
||||
|
||||
@@ -1,152 +1,198 @@
|
||||
window.testSuites.push( class testParse {
|
||||
|
||||
testParseConstructor() {
|
||||
class Space extends Shadow {
|
||||
form
|
||||
contents = []
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
testParseConstructor() {
|
||||
class Space extends Shadow {
|
||||
form
|
||||
contents = []
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let newClass = window.Registry.parseConstructor(Space)
|
||||
if(!newClass.prototype.constructor.toString().includes("window.Registry.construct(")) {
|
||||
return "'window.Registry.construct(' not detected!"
|
||||
}
|
||||
}
|
||||
|
||||
testParseConstructorIfNoneProvided() {
|
||||
class Space extends Shadow {
|
||||
$form
|
||||
}
|
||||
|
||||
let newClass = window.Registry.parseConstructor(Space)
|
||||
if(!newClass.prototype.constructor.toString().includes("window.Registry.construct(")) {
|
||||
return "'window.Registry.construct(' not detected!"
|
||||
}
|
||||
}
|
||||
|
||||
testParseConstructorFailsIfNoSuper() {
|
||||
class Space extends Shadow {
|
||||
form
|
||||
contents = []
|
||||
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
let newClass = window.Registry.parseConstructor(Space)
|
||||
return "No error thrown!"
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testParseClassFieldsWithNoDefault() {
|
||||
class Space extends Shadow {
|
||||
form
|
||||
contents = []
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
if(!newClass.prototype.constructor.toString().includes("window.Registry.construct(")) {
|
||||
return "'window.Registry.construct(' not detected!"
|
||||
}
|
||||
}
|
||||
|
||||
const fields = window.Registry.parseClassFields(Space);
|
||||
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
|
||||
return `Fields don't match`
|
||||
}
|
||||
}
|
||||
testParseConstructorIfNoneProvided() {
|
||||
class Space extends Shadow {
|
||||
$form
|
||||
}
|
||||
|
||||
testParseClassFieldsWithEqualityCheck() {
|
||||
class Space extends Shadow {
|
||||
form = Forms.observe(window.location.pathname, this)
|
||||
|
||||
contents = [
|
||||
...this.form.children.map(form => {
|
||||
switch(form.type) {
|
||||
case "file" === "file":
|
||||
return File(form)
|
||||
case "space":
|
||||
return ChildSpace(form)
|
||||
case "link":
|
||||
return Link()
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
let newClass = window.Registry.parseConstructor(Space)
|
||||
if(!newClass.prototype.constructor.toString().includes("window.Registry.construct(")) {
|
||||
return "'window.Registry.construct(' not detected!"
|
||||
}
|
||||
}
|
||||
|
||||
const fields = window.Registry.parseClassFields(Space);
|
||||
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
|
||||
return `Fields don't match`
|
||||
}
|
||||
}
|
||||
testParseConstructorFailsIfNoSuper() {
|
||||
class Space extends Shadow {
|
||||
form
|
||||
contents = []
|
||||
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
testParseClassFieldsWithInnerFunctionVariable() {
|
||||
class Space extends Shadow {
|
||||
form = Forms.observe(window.location.pathname, this)
|
||||
|
||||
contents = [
|
||||
...this.form.children.map(form => {
|
||||
let file;
|
||||
file = "hey"
|
||||
switch(form.type) {
|
||||
case "file" === "file":
|
||||
return File(form)
|
||||
case "space":
|
||||
return ChildSpace(form)
|
||||
case "link":
|
||||
return Link()
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
try {
|
||||
let newClass = window.Registry.parseConstructor(Space)
|
||||
return "No error thrown!"
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testParseClassFieldsWithNoDefault() {
|
||||
class Space extends Shadow {
|
||||
form
|
||||
contents = []
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
}
|
||||
}
|
||||
|
||||
const fields = window.Registry.parseClassFields(Space);
|
||||
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
|
||||
return `Fields don't match`
|
||||
}
|
||||
}
|
||||
|
||||
const fields = window.Registry.parseClassFields(Space);
|
||||
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
|
||||
return `Fields don't match`
|
||||
}
|
||||
}
|
||||
testParseClassFieldsWithEqualityCheck() {
|
||||
class Space extends Shadow {
|
||||
form = Forms.observe(window.location.pathname, this)
|
||||
|
||||
contents = [
|
||||
...this.form.children.map(form => {
|
||||
switch(form.type) {
|
||||
case "file" === "file":
|
||||
return File(form)
|
||||
case "space":
|
||||
return ChildSpace(form)
|
||||
case "link":
|
||||
return Link()
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
}
|
||||
}
|
||||
|
||||
ParseConstructorWithFunctionsBelow() {
|
||||
class Space extends Shadow {
|
||||
$$form = Forms.observe(window.location.pathname, this)
|
||||
|
||||
render = () => {
|
||||
ForEach(this.form.children, (form) => {
|
||||
switch(form.type) {
|
||||
case "file":
|
||||
File(form)
|
||||
break
|
||||
case "space":
|
||||
ChildSpace(form)
|
||||
break
|
||||
case "link":
|
||||
Link()
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
const fields = window.Registry.parseClassFields(Space);
|
||||
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
|
||||
return `Fields don't match`
|
||||
}
|
||||
}
|
||||
|
||||
window.Registry.parseConstructor(Space)
|
||||
}
|
||||
|
||||
testParseClassFieldsWithInnerFunctionVariable() {
|
||||
class Space extends Shadow {
|
||||
form = Forms.observe(window.location.pathname, this)
|
||||
|
||||
contents = [
|
||||
...this.form.children.map(form => {
|
||||
let file;
|
||||
file = "hey"
|
||||
switch(form.type) {
|
||||
case "file" === "file":
|
||||
return File(form)
|
||||
case "space":
|
||||
return ChildSpace(form)
|
||||
case "link":
|
||||
return Link()
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
}
|
||||
}
|
||||
|
||||
const fields = window.Registry.parseClassFields(Space);
|
||||
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
|
||||
return `Fields don't match`
|
||||
}
|
||||
}
|
||||
|
||||
ParseConstructorWithFunctionsBelow() {
|
||||
class Space extends Shadow {
|
||||
$$form = Forms.observe(window.location.pathname, this)
|
||||
|
||||
render = () => {
|
||||
ForEach(this.form.children, (form) => {
|
||||
switch(form.type) {
|
||||
case "file":
|
||||
File(form)
|
||||
break
|
||||
case "space":
|
||||
ChildSpace(form)
|
||||
break
|
||||
case "link":
|
||||
Link()
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
}
|
||||
}
|
||||
|
||||
window.Registry.parseConstructor(Space)
|
||||
}
|
||||
|
||||
ParseRender() {
|
||||
class Sidebar extends Shadow {
|
||||
$$windowState = windowState
|
||||
$$form = Forms.observe(window.location.pathname)
|
||||
$sidebarPos = -200
|
||||
|
||||
render = () => {
|
||||
VStack(() => {
|
||||
ForEach(this.form.children, (form) => {
|
||||
switch(form.constructor.name) {
|
||||
case "File":
|
||||
SidebarFile(form)
|
||||
break
|
||||
case "Space":
|
||||
SidebarSpace(form)
|
||||
break
|
||||
}
|
||||
})
|
||||
})
|
||||
.background("black")
|
||||
.positionType("absolute")
|
||||
.x(this.windowState.sidebarOut ? 0 : -200)
|
||||
.y(0)
|
||||
.width(200, "px")
|
||||
.height(100, "vh")
|
||||
}
|
||||
}
|
||||
|
||||
let result = Registry.parseRender(Sidebar)
|
||||
console.log(result)
|
||||
|
||||
let expectedOutput = "[[VStack.ForEach, form.children], [VStack.x, windowState.sidebarOut]]"
|
||||
|
||||
if(JSON.stringify(result) !== JSON.stringify(expectedOutput)) {
|
||||
return "Result does not match expected array!"
|
||||
}
|
||||
}
|
||||
|
||||
CopyTo() {
|
||||
let str = "render=()=>{VStack(()=>{"
|
||||
let ret = str.copyTo("{")
|
||||
console.log(ret)
|
||||
|
||||
if(ret !== "render=()=>") return "Copy 1 failed!"
|
||||
}
|
||||
|
||||
})
|
||||
18
Test/test.js
18
Test/test.js
@@ -2,9 +2,9 @@ console.log("Tests initializing.")
|
||||
window.testSuites = [];
|
||||
|
||||
await import ("./parse.test.js")
|
||||
await import ("./init.test.js")
|
||||
await import ("./render.test.js")
|
||||
await import ("./observedobject.test.js")
|
||||
// await import ("./init.test.js")
|
||||
// await import ("./render.test.js")
|
||||
// await import ("./observedobject.test.js")
|
||||
|
||||
window.randomName = function randomName(prefix) {
|
||||
const sanitizedPrefix = prefix.toLowerCase().replace(/[^a-z0-9]/g, '');
|
||||
@@ -75,13 +75,13 @@ window.test = async function() {
|
||||
console.log("")
|
||||
let elapsed = new Date() - start;
|
||||
if(failed === 0) {
|
||||
console.log(`%cRan ${failed+success} tests in ${elapsed}ms`, 'background: #222; color: #00FF00');
|
||||
console.log(`%c ${success} passed`, 'background: #222; color: #00FF00');
|
||||
console.log(`%c ${failed} failed`, 'background: #222;');
|
||||
console.log(`%cRan ${failed+success} tests in ${elapsed}ms`, 'color: #00FF00');
|
||||
console.log(`%c ${success} passed`, 'color: #00FF00');
|
||||
console.log(`%c ${failed} failed`);
|
||||
} else {
|
||||
console.log(`%cRan ${failed+success} tests in ${elapsed}ms`, 'background: #222; color: rgb(254, 62, 43)');
|
||||
console.log(`%c ${success} `, 'background: #222; color: #00FF00', "passed");
|
||||
console.log(`%c ${failed} failed`, 'background: #222; color: rgb(254, 62, 43)');
|
||||
console.log(`%cRan ${failed+success} tests in ${elapsed}ms`, 'color: rgb(254, 62, 43)');
|
||||
console.log(`%c ${success} `, 'color: #00FF00', "passed");
|
||||
console.log(`%c ${failed} failed`, 'color: rgb(254, 62, 43)');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user