fix tests; add comprehensive tests for functions and fix bugs in the mach VM regarding them.
This commit is contained in:
@@ -2486,14 +2486,32 @@ vm_dispatch:
|
||||
VM_CASE(MACH_IS_WS): {
|
||||
JSValue v = frame->slots[b];
|
||||
int result = 0;
|
||||
if (MIST_IsImmediateASCII(v) && MIST_GetImmediateASCIILen(v) == 1) {
|
||||
int ch = MIST_GetImmediateASCIIChar(v, 0);
|
||||
result = (ch == ' ' || ch == '\t' || ch == '\n'
|
||||
|| ch == '\r' || ch == '\f' || ch == '\v');
|
||||
} else if (mist_is_text(v) && js_string_value_len(v) == 1) {
|
||||
uint32_t ch = js_string_value_get(v, 0);
|
||||
result = (ch == ' ' || ch == '\t' || ch == '\n'
|
||||
|| ch == '\r' || ch == '\f' || ch == '\v');
|
||||
if (MIST_IsImmediateASCII(v)) {
|
||||
int len = MIST_GetImmediateASCIILen(v);
|
||||
if (len > 0) {
|
||||
result = 1;
|
||||
for (int i = 0; i < len; i++) {
|
||||
int ch = MIST_GetImmediateASCIIChar(v, i);
|
||||
if (!(ch == ' ' || ch == '\t' || ch == '\n'
|
||||
|| ch == '\r' || ch == '\f' || ch == '\v')) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (mist_is_text(v)) {
|
||||
int len = js_string_value_len(v);
|
||||
if (len > 0) {
|
||||
result = 1;
|
||||
for (int i = 0; i < len; i++) {
|
||||
uint32_t ch = js_string_value_get(v, i);
|
||||
if (!(ch == ' ' || ch == '\t' || ch == '\n'
|
||||
|| ch == '\r' || ch == '\f' || ch == '\v')) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
frame->slots[a] = JS_NewBool(ctx, result);
|
||||
VM_BREAK();
|
||||
|
||||
Reference in New Issue
Block a user