rm js fns

This commit is contained in:
2026-01-16 17:44:14 -06:00
parent ac91495679
commit b46406f755
42 changed files with 1954 additions and 2335 deletions

38
test.ce
View File

@@ -84,7 +84,7 @@ function parse_args() {
var lock = shop.load_lock()
if (lock[name]) {
target_pkg = name
} else if (name.startsWith('/') && is_valid_package(name)) {
} else if (starts_with(name, '/') && is_valid_package(name)) {
target_pkg = name
} else {
// Try to resolve as dependency alias from current package
@@ -115,7 +115,7 @@ function parse_args() {
var test_path = args[0]
// Normalize path - add tests/ prefix if not present and doesn't start with /
if (!test_path.startsWith('tests/') && !test_path.startsWith('/')) {
if (!starts_with(test_path, 'tests/') && !starts_with(test_path, '/')) {
// Check if file exists as-is first
if (!fd.is_file(test_path + '.cm') && !fd.is_file(test_path)) {
// Try with tests/ prefix
@@ -144,8 +144,8 @@ if (!parse_args()) {
function ensure_dir(path) {
if (fd.is_dir(path)) return true
var parts = path.split('/')
var current = path.startsWith('/') ? '/' : ''
var parts = array(path, '/')
var current = starts_with(path, '/') ? '/' : ''
for (var i = 0; i < parts.length; i++) {
if (parts[i] == '') continue
current += parts[i] + '/'
@@ -161,7 +161,7 @@ function get_pkg_dir(package_name) {
if (!package_name) {
return fd.realpath('.')
}
if (package_name.startsWith('/')) {
if (starts_with(package_name, '/')) {
return package_name
}
return shop.get_package_dir(package_name)
@@ -179,16 +179,16 @@ function collect_actor_tests(package_name, specific_test) {
for (var i = 0; i < files.length; i++) {
var f = files[i]
// Check if file is in tests/ folder and is a .ce actor
if (f.startsWith("tests/") && f.endsWith(".ce")) {
if (starts_with(f, "tests/") && ends_with(f, ".ce")) {
// If specific test requested, filter
if (specific_test) {
var test_name = f.substring(0, f.length - 3) // remove .ce
var test_name = text(f, 0, -3) // remove .ce
var match_name = specific_test
if (!match_name.startsWith('tests/')) match_name = 'tests/' + match_name
if (!match_name.endsWith('.ce')) match_name = match_name
if (!starts_with(match_name, 'tests/')) match_name = 'tests/' + match_name
if (!ends_with(match_name, '.ce')) match_name = match_name
// Match without extension
var test_base = test_name
var match_base = match_name.endsWith('.ce') ? match_name.substring(0, match_name.length - 3) : match_name
var match_base = ends_with(match_name, '.ce') ? text(match_name, 0, -3) : match_name
if (test_base != match_base) continue
}
@@ -204,7 +204,7 @@ function collect_actor_tests(package_name, specific_test) {
// Spawn an actor test and track it
function spawn_actor_test(test_info) {
var test_name = test_info.file.substring(6, test_info.file.length - 3) // remove "tests/" and ".ce"
var test_name = text(test_info.file, 6, -3) // remove "tests/" and ".ce"
log.console(` [ACTOR] ${test_info.file}`)
var entry = {
@@ -218,7 +218,7 @@ function spawn_actor_test(test_info) {
try {
// Spawn the actor test - it should send back results
var actor_path = test_info.path.substring(0, test_info.path.length - 3) // remove .ce
var actor_path = text(test_info.path, 0, -3) // remove .ce
entry.actor = $start(actor_path)
pending_actor_tests.push(entry)
} catch (e) {
@@ -250,14 +250,14 @@ function run_tests(package_name, specific_test) {
for (var i = 0; i < files.length; i++) {
var f = files[i]
// Check if file is in tests/ folder and is a .cm module (not .ce - those are actor tests)
if (f.startsWith("tests/") && f.endsWith(".cm")) {
if (starts_with(f, "tests/") && ends_with(f, ".cm")) {
// If specific test requested, filter
if (specific_test) {
var test_name = f.substring(0, f.length - 3) // remove .cm
var test_name = text(f, 0, -3) // remove .cm
var match_name = specific_test
if (!match_name.startsWith('tests/')) match_name = 'tests/' + match_name
if (!starts_with(match_name, 'tests/')) match_name = 'tests/' + match_name
// Match without extension
var match_base = match_name.endsWith('.cm') ? match_name.substring(0, match_name.length - 3) : match_name
var match_base = ends_with(match_name, '.cm') ? text(match_name, 0, -3) : match_name
if (test_name != match_base) continue
}
test_files.push(f)
@@ -271,7 +271,7 @@ function run_tests(package_name, specific_test) {
for (var i = 0; i < test_files.length; i++) {
var f = test_files[i]
var mod_path = f.substring(0, f.length - 3) // remove .cm
var mod_path = text(f, 0, -3) // remove .cm
var file_result = {
name: f,
@@ -336,7 +336,7 @@ function run_tests(package_name, specific_test) {
log.console(` FAIL ${t.name} ${test_entry.error.message}`)
if (test_entry.error.stack) {
log.console(` ${text(test_entry.error.stack.split('\n'), '\n ')}`)
log.console(` ${text(array(test_entry.error.stack, '\n'), '\n ')}`)
}
pkg_result.failed++
@@ -602,7 +602,7 @@ Total: ${totals.total}, Passed: ${totals.passed}, Failed: ${totals.failed}
if (t.error) {
txt_report += ` Message: ${t.error.message}\n`
if (t.error.stack) {
txt_report += ` Stack:\n${text(t.error.stack.split('\n').map(function(l){return ` ${l}`}), '\n')}\n`
txt_report += ` Stack:\n${text(array(array(t.error.stack, '\n'), l => ` ${l}`), '\n')}\n`
}
}
txt_report += `\n`