This commit is contained in:
parent
bd9de85ffc
commit
aca83f7235
3 changed files with 55 additions and 33 deletions
|
|
@ -1,37 +1,56 @@
|
|||
term = document.querySelector('[isoterminal]').components.isoterminal.term
|
||||
convert = ISOTerminal.prototype.convert
|
||||
isoterminal = document.querySelector("[isoterminal]")
|
||||
|
||||
console.test("com/isoterminal/ISOTerminal.js", async () => {
|
||||
isoterminal.addEventListener("ready", function(){
|
||||
|
||||
term = isoterminal.components.isoterminal.term
|
||||
convert = ISOTerminal.prototype.convert
|
||||
|
||||
console.test.tests = {} // empty previous tests
|
||||
|
||||
console.test("com/isoterminal/ISOTerminal.js", async () => {
|
||||
|
||||
term.worker.create_file("foo", convert.toUint8Array("hello") )
|
||||
.then( (res) => {
|
||||
term.worker.read_file("foo")
|
||||
.then( (res) => {
|
||||
try{
|
||||
let data = convert.Uint8ArrayToString( res )
|
||||
console.assert( data == "hello", "worker.create_file")
|
||||
}catch(e){
|
||||
console.assert( false, "worker.create_file")
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(console.error)
|
||||
.finally(console.dir)
|
||||
|
||||
term.worker.read_file("root/.profile")
|
||||
.then( (res) => {
|
||||
try{
|
||||
let data = convert.Uint8ArrayToString( res )
|
||||
console.assert( data.length, "worker.postMessage.promise()")
|
||||
}catch(e){
|
||||
console.assert( false, "worker.postMessage.promise()")
|
||||
}
|
||||
})
|
||||
.catch(console.error)
|
||||
.finally(console.dir)
|
||||
|
||||
})
|
||||
console.test("com/isoterminal/ISOTerminal.js", async () => {
|
||||
|
||||
console.test("com/isoterminal/ISOTerminal.js", async () => {
|
||||
|
||||
term.worker.create_file("foo", convert.toUint8Array("hello") )
|
||||
.then( (res) => {
|
||||
term.worker.read_file("foo")
|
||||
.then( (res) => {
|
||||
try{
|
||||
let data = convert.Uint8ArrayToString( res )
|
||||
console.assert( data == "hello", "worker.create_file")
|
||||
console.assert( data.length && data == "hello", "worker.postMessage.promise()")
|
||||
}catch(e){
|
||||
console.assert( false, "worker.create_file")
|
||||
console.assert( false, "worker.postMessage.promise()")
|
||||
}
|
||||
})
|
||||
.catch(console.error)
|
||||
.finally(console.dir)
|
||||
|
||||
})
|
||||
.catch(console.error)
|
||||
.finally(console.dir)
|
||||
|
||||
|
||||
console.test.run()
|
||||
|
||||
})
|
||||
|
||||
console.test("com/isoterminal.js", async () => {
|
||||
console.assert( AFRAME.components.isoterminal != undefined, "AFRAME.components.isoterminal")
|
||||
})
|
||||
|
||||
console.test("xrsh.iso", async () => {
|
||||
console.assert( false, "create testsuite.zip package which tests iso")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
const run = async function(){
|
||||
await AFRAME.utils.require({
|
||||
"test_util": "tests/util.js",
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
|
||||
// minimalistc testrunner
|
||||
console.test = async (name,cb) => {
|
||||
window.console.test = async (name,cb) => {
|
||||
let tests = console.test.tests = console.test.tests || {}
|
||||
tests[name] = tests[name] || []
|
||||
tests[name].push(cb)
|
||||
console.test.run = async (cb) => {
|
||||
for( let name in tests ){
|
||||
console.log("\x1b[34m\x1b[36;49m"+name+"\x1B[m")
|
||||
for( let test in tests[name] ){
|
||||
await tests[name][test]()
|
||||
}
|
||||
}
|
||||
if( cb ) cb()
|
||||
}
|
||||
}
|
||||
|
||||
console.assert = ((assert) => (a,reason,data) => {
|
||||
window.console.test.run = async (cb) => {
|
||||
const tests = window.console.test.tests
|
||||
for( let name in tests ){
|
||||
console.log("\x1b[34m\x1b[36;49m"+name+"\x1B[m")
|
||||
for( let test in tests[name] ){
|
||||
await tests[name][test]()
|
||||
}
|
||||
}
|
||||
if( cb ) cb()
|
||||
}
|
||||
|
||||
window.console.assert = ((assert) => (a,reason,data) => {
|
||||
console.log("\x1b[34m\x1b[36;49m♥ \x1B[m"+reason)
|
||||
assert.call( console, a, {reason} )
|
||||
if( !a ){
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue