remove isa

This commit is contained in:
2026-01-06 11:17:07 -06:00
parent 63cf76dcf9
commit dd309b1a37
10 changed files with 43 additions and 78 deletions

View File

@@ -37,7 +37,7 @@ function deepCompare(expected, actual, path) {
};
}
if ((expected instanceof blob) && (actual instanceof blob)) {
if (is_blob(expected) && is_blob(actual)) {
stone_if_needed(expected); stone_if_needed(actual)
if (expected.length != actual.length)
return { passed: false, messages: [`blob length mismatch at ${path}: ${expected.length} vs ${actual.length}`] }
@@ -48,7 +48,7 @@ function deepCompare(expected, actual, path) {
return { passed: true, messages: [] }
}
if (isa(expected, array) && isa(actual, array)) {
if (is_array(expected) && is_array(actual)) {
if (expected.length != actual.length)
return {
passed: false,
@@ -64,7 +64,7 @@ function deepCompare(expected, actual, path) {
return { passed: messages.length == 0, messages: messages };
}
if (isa(expected, object) && isa(actual, object)) {
if (is_object(expected) && is_object(actual)) {
var expKeys = array(expected).sort();
var actKeys = array(actual).sort();
if (JSON.stringify(expKeys) != JSON.stringify(actKeys))
@@ -91,7 +91,7 @@ function deepCompare(expected, actual, path) {
function makeTest(test) {
return function() {
var encoded = test.replacer ? nota.encode(test.input, test.replacer) : nota.encode(test.input);
if (!(encoded instanceof blob)){
if (!is_blob(encoded)){
throw "encode() should return blob";
}

View File

@@ -1018,38 +1018,38 @@ return {
// ============================================================================
test_isa_number: function() {
if (!isa(42, number)) throw "isa number failed"
if (isa("42", number)) throw "isa string not number failed"
if (!is_number(42)) throw "isa number failed"
if (is_number("42")) throw "isa string not number failed"
},
test_isa_text: function() {
if (!isa("hello", text)) throw "isa text failed"
if (isa(123, text)) throw "isa number not text failed"
if (!is_text("hello")) throw "isa text failed"
if (is_text(123)) throw "isa number not text failed"
},
test_isa_logical: function() {
if (!isa(true, logical)) throw "isa true failed"
if (!isa(false, logical)) throw "isa false failed"
if (isa(1, logical)) throw "isa number not logical failed"
if (!is_logical(true)) throw "isa true failed"
if (!is_logical(false)) throw "isa false failed"
if (is_logical(1)) throw "isa number not logical failed"
},
test_isa_array: function() {
if (!isa([], array)) throw "isa empty array failed"
if (!isa([1,2,3], array)) throw "isa array failed"
if (isa({}, array)) throw "isa object not array failed"
if (!is_array([], array)) throw "isa empty array failed"
if (!is_array([1,2,3], array)) throw "isa array failed"
if (is_array({}, array)) throw "isa object not array failed"
},
test_isa_object: function() {
if (!isa({}, object)) throw "isa empty object failed"
if (!isa({a:1}, object)) throw "isa object failed"
if (isa([], object)) throw "isa array not object failed"
if (isa(null, object)) throw "isa null not object failed"
if (!is_object({}, object)) throw "isa empty object failed"
if (!is_object({a:1}, object)) throw "isa object failed"
if (is_object([], object)) throw "isa array not object failed"
if (is_object(null, object)) throw "isa null not object failed"
},
test_isa_null: function() {
if (isa(null, number)) throw "null not number"
if (isa(null, text)) throw "null not text"
if (isa(null, object)) throw "null not object"
if (is_null(null)) throw "null not number"
if (is_null(text)) throw "null not text"
if (is_null(object)) throw "null not object"
},
// ============================================================================

View File

@@ -30,7 +30,7 @@ function deep_compare(expected, actual, path) {
return { passed: true, messages: [] }
}
if (isa(expected, array) && isa(actual, array)) {
if (is_array(expected) && is_array(actual)) {
if (expected.length != actual.length)
return { passed: false, messages: [`Array length mismatch at ${path}: ${expected.length} vs ${actual.length}`] }
var msgs = []
@@ -43,7 +43,7 @@ function deep_compare(expected, actual, path) {
return { passed: msgs.length == 0, messages: msgs }
}
if (isa(expected, object) && isa(actual, object)) {
if (is_object(expected) && is_object(actual)) {
var expKeys = array(expected).sort()
var actKeys = array(actual).sort()
if (JSON.stringify(expKeys) != JSON.stringify(actKeys))