Add asm.js sanity test.
This commit is contained in:
14
Makefile
14
Makefile
@ -92,6 +92,8 @@ LINK64 = "$(shell $(LSQ) ${MSVS}/*/*/VC/Tools/MSVC/*/bin/Hostx86/x64/link.exe |
|
|||||||
RC32 = "$(shell $(LSQ) ${MSKITS}/*/bin/*/x86/rc.exe | head -n 1)"
|
RC32 = "$(shell $(LSQ) ${MSKITS}/*/bin/*/x86/rc.exe | head -n 1)"
|
||||||
RC64 = "$(shell $(LSQ) ${MSKITS}/*/bin/*/x64/rc.exe | head -n 1)"
|
RC64 = "$(shell $(LSQ) ${MSKITS}/*/bin/*/x64/rc.exe | head -n 1)"
|
||||||
|
|
||||||
|
D8 = "$(shell $(LSQ) ${HOME}/src/v8/v8/out/x64.release/d8)"
|
||||||
|
|
||||||
# Selectively enable windows if tools available
|
# Selectively enable windows if tools available
|
||||||
DEPLOYABLE := 1
|
DEPLOYABLE := 1
|
||||||
ifneq ("", $(CL32))
|
ifneq ("", $(CL32))
|
||||||
@ -127,6 +129,11 @@ else
|
|||||||
$(warning "Missing some platforms skipping deployment build.")
|
$(warning "Missing some platforms skipping deployment build.")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Decide if we have d8.
|
||||||
|
ifneq ("", $(D8))
|
||||||
|
TESTS += web_tests
|
||||||
|
endif
|
||||||
|
|
||||||
all: targets tests $(DEPLOY_TARGETS)
|
all: targets tests $(DEPLOY_TARGETS)
|
||||||
fast: posix esp32_sim esp32
|
fast: posix esp32_sim esp32
|
||||||
|
|
||||||
@ -141,7 +148,7 @@ clean:
|
|||||||
posix_tests: unit_tests_posix see_all_test_posix save_restore_test
|
posix_tests: unit_tests_posix see_all_test_posix save_restore_test
|
||||||
win32_tests: unit_tests_win32
|
win32_tests: unit_tests_win32
|
||||||
win64_tests: unit_tests_win64
|
win64_tests: unit_tests_win64
|
||||||
web_tests:
|
web_tests: sanity_test_web
|
||||||
esp32_tests:
|
esp32_tests:
|
||||||
esp32_sim_tests: unit_tests_esp32_sim see_all_test_esp32_sim sizes
|
esp32_sim_tests: unit_tests_esp32_sim see_all_test_esp32_sim sizes
|
||||||
|
|
||||||
@ -177,6 +184,9 @@ save_restore_test: $(POSIX)/ueforth
|
|||||||
sizes: $(ESP32_SIM)/Esp32forth-sim
|
sizes: $(ESP32_SIM)/Esp32forth-sim
|
||||||
echo internals size-all bye | $< | tools/memuse.py >$(ESP32_SIM)/sizes.txt
|
echo internals size-all bye | $< | tools/memuse.py >$(ESP32_SIM)/sizes.txt
|
||||||
|
|
||||||
|
sanity_test_web: $(WEB)/ueforth.js
|
||||||
|
echo '120 3 + . cr bye' | $(D8) $< | tools/check_web_sanity.js
|
||||||
|
|
||||||
# ---- GENERATED ----
|
# ---- GENERATED ----
|
||||||
|
|
||||||
$(GEN):
|
$(GEN):
|
||||||
@ -568,7 +578,7 @@ deploy: all
|
|||||||
cd out/deploy && gcloud app deploy -q --project esp32forth *.yaml
|
cd out/deploy && gcloud app deploy -q --project esp32forth *.yaml
|
||||||
cd out/deploy && gcloud app deploy -q --project eforth *.yaml
|
cd out/deploy && gcloud app deploy -q --project eforth *.yaml
|
||||||
|
|
||||||
d8:
|
d8: web
|
||||||
${HOME}/src/v8/v8/out/x64.release/d8 out/web/ueforth.js
|
${HOME}/src/v8/v8/out/x64.release/d8 out/web/ueforth.js
|
||||||
|
|
||||||
# ---- INSTALL ----
|
# ---- INSTALL ----
|
||||||
|
|||||||
31
tools/check_web_sanity.js
Normal file
31
tools/check_web_sanity.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#! /usr/bin/env nodejs
|
||||||
|
// Copyright 2022 Bradley D. Nelson
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var process = require('process');
|
||||||
|
|
||||||
|
var source = fs.readFileSync(process.stdin.fd).toString();
|
||||||
|
|
||||||
|
if (source.match(/Invalid/)) {
|
||||||
|
console.log('BAD ASM.JS');
|
||||||
|
console.log(source);
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!source.match(/[-][-][>] 123[ \r\n]+$/)) {
|
||||||
|
console.log('MISSING EXPECTED OUTPUT');
|
||||||
|
console.log(source);
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
47
web/fini.fs
47
web/fini.fs
@ -33,6 +33,7 @@ r|
|
|||||||
: jseval ( a n -- ) 1 call ;
|
: jseval ( a n -- ) 1 call ;
|
||||||
|
|
||||||
r"
|
r"
|
||||||
|
globalObj.inbuffer = [];
|
||||||
if (!globalObj['write']) {
|
if (!globalObj['write']) {
|
||||||
var con = document.getElementById('console');
|
var con = document.getElementById('console');
|
||||||
if (con === null) {
|
if (con === null) {
|
||||||
@ -40,14 +41,13 @@ r"
|
|||||||
con.id = 'console';
|
con.id = 'console';
|
||||||
document.body.appendChild(con);
|
document.body.appendChild(con);
|
||||||
}
|
}
|
||||||
window.inbuffer = [];
|
|
||||||
window.outbuffer = '';
|
window.outbuffer = '';
|
||||||
window.onkeypress = function(e) {
|
window.onkeypress = function(e) {
|
||||||
window.inbuffer.push(e.keyCode);
|
globalObj.inbuffer.push(e.keyCode);
|
||||||
};
|
};
|
||||||
window.onkeydown = function(e) {
|
window.onkeydown = function(e) {
|
||||||
if (e.keyCode == 8) {
|
if (e.keyCode == 8) {
|
||||||
window.inbuffer.push(e.keyCode);
|
globalObj.inbuffer.push(e.keyCode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -84,8 +84,15 @@ r|
|
|||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
if (window.inbuffer.length) {
|
if (globalObj['readline'] && !globalObj.inbuffer.length) {
|
||||||
sp += 4; i32[sp>>2] = window.inbuffer.shift();
|
var line = readline();
|
||||||
|
for (var i = 0; i < line.length; ++i) {
|
||||||
|
globalObj.inbuffer.push(line.charCodeAt(i));
|
||||||
|
}
|
||||||
|
globalObj.inbuffer.push(13);
|
||||||
|
}
|
||||||
|
if (globalObj.inbuffer.length) {
|
||||||
|
sp += 4; i32[sp>>2] = globalObj.inbuffer.shift();
|
||||||
} else {
|
} else {
|
||||||
sp += 4; i32[sp>>2] = 0;
|
sp += 4; i32[sp>>2] = 0;
|
||||||
}
|
}
|
||||||
@ -97,13 +104,41 @@ r|
|
|||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
sp += 4; i32[sp>>2] = window.inbuffer.length ? -1 : 0;
|
if (globalObj['readline']) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
sp += 4; i32[sp>>2] = globalObj.inbuffer.length ? -1 : 0;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 4 jseval!
|
| 4 jseval!
|
||||||
: web-key? ( -- f ) yield 4 call ;
|
: web-key? ( -- f ) yield 4 call ;
|
||||||
' web-key? is key?
|
' web-key? is key?
|
||||||
|
|
||||||
|
r|
|
||||||
|
(function(sp) {
|
||||||
|
var val = i32[sp>>2]; sp -= 4;
|
||||||
|
if (globalObj['quit']) {
|
||||||
|
quit(val);
|
||||||
|
} else {
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
return sp;
|
||||||
|
})
|
||||||
|
| 5 jseval!
|
||||||
|
: terminate ( n -- ) 5 call ;
|
||||||
|
: bye 0 terminate ;
|
||||||
|
|
||||||
|
r|
|
||||||
|
(function(sp) {
|
||||||
|
if (globalObj['write']) {
|
||||||
|
sp += 4; i32[sp>>2] = 0; // Disable echo.
|
||||||
|
} else {
|
||||||
|
sp += 4; i32[sp>>2] = -1; // Enable echo.
|
||||||
|
}
|
||||||
|
return sp;
|
||||||
|
})
|
||||||
|
| 6 jseval! 6 call echo !
|
||||||
|
|
||||||
: page 12 emit ;
|
: page 12 emit ;
|
||||||
|
|
||||||
transfer forth
|
transfer forth
|
||||||
|
|||||||
Reference in New Issue
Block a user