Compare commits
4 Commits
b23b918f97
...
f2a76cbb55
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2a76cbb55 | ||
|
|
2d834c37b3 | ||
|
|
ba1b92aa78 | ||
|
|
c356fe462d |
@@ -166,7 +166,7 @@ static void nota_encode_value(NotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
case JS_TAG_NULL:
|
||||
nota_write_sym(&enc->nb, NOTA_NULL);
|
||||
break;
|
||||
case JS_TAG_OBJECT: {
|
||||
case JS_TAG_PTR: {
|
||||
if (js_is_blob(ctx, replaced)) {
|
||||
size_t buf_len;
|
||||
void *buf_data = js_get_blob_data(ctx, &buf_len, replaced);
|
||||
|
||||
@@ -156,7 +156,7 @@ static void wota_encode_value(WotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
case JS_TAG_NULL:
|
||||
wota_write_sym(&enc->wb, WOTA_NULL);
|
||||
break;
|
||||
case JS_TAG_OBJECT: {
|
||||
case JS_TAG_PTR: {
|
||||
if (js_is_blob(ctx, replaced)) {
|
||||
size_t buf_len;
|
||||
void *buf_data = js_get_blob_data(ctx, &buf_len, replaced);
|
||||
|
||||
1498
source/quickjs.c
1498
source/quickjs.c
File diff suppressed because it is too large
Load Diff
@@ -153,7 +153,6 @@ enum {
|
||||
|
||||
/* Compatibility tag aliases for external code */
|
||||
#define JS_TAG_STRING JS_TAG_STRING_IMM /* Alias: text/string type */
|
||||
#define JS_TAG_OBJECT JS_TAG_PTR /* Alias: use JS_IsRecord/JS_IsArray instead */
|
||||
#define JS_TAG_FLOAT64 JS_TAG_SHORT_FLOAT /* Alias: floats use short float encoding */
|
||||
|
||||
#define JS_EMPTY_TEXT ((JSValue)JS_TAG_STRING_IMM)
|
||||
@@ -241,8 +240,8 @@ __JS_NewFloat64 (JSContext *ctx, double d) {
|
||||
int exp = (u.u >> 52) & 0x7FF;
|
||||
uint64_t mantissa = u.u & ((1ULL << 52) - 1);
|
||||
|
||||
/* Zero → short float zero */
|
||||
if (exp == 0 && mantissa == 0) { return (sign << 63) | JS_TAG_SHORT_FLOAT; }
|
||||
/* Zero → short float zero (always +0, no -0) */
|
||||
if (exp == 0 && mantissa == 0) { return JS_TAG_SHORT_FLOAT; }
|
||||
|
||||
/* NaN/Inf → NULL */
|
||||
if (exp == 0x7FF) { return JS_MKVAL (JS_TAG_NULL, 0); }
|
||||
@@ -274,7 +273,7 @@ static inline double JS_VALUE_GET_FLOAT64 (JSValue v) {
|
||||
uint64_t short_exp = (v >> 55) & 0xFF;
|
||||
uint64_t mantissa = (v >> 3) & ((1ULL << 52) - 1);
|
||||
|
||||
if (short_exp == 0) return sign ? -0.0 : 0.0;
|
||||
if (short_exp == 0) return 0.0; /* Always +0, no -0 */
|
||||
|
||||
uint64_t exp = short_exp - 127 + 1023;
|
||||
union {
|
||||
@@ -398,6 +397,7 @@ void JS_FreeRuntime (JSRuntime *rt);
|
||||
void *JS_GetRuntimeOpaque (JSRuntime *rt);
|
||||
void JS_SetRuntimeOpaque (JSRuntime *rt, void *opaque);
|
||||
typedef void JS_MarkFunc (JSRuntime *rt, JSGCObjectHeader *gp);
|
||||
/* JS_MarkValue is a no-op with copying GC (values are traced from roots) */
|
||||
void JS_MarkValue (JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func);
|
||||
void JS_RunGC (JSRuntime *rt);
|
||||
JS_BOOL JS_IsLiveObject (JSRuntime *rt, JSValue obj);
|
||||
@@ -642,7 +642,6 @@ JSValue __js_printf_like (2, 3)
|
||||
JSValue JS_ThrowOutOfMemory (JSContext *ctx);
|
||||
|
||||
JS_BOOL JS_StrictEq (JSContext *ctx, JSValue op1, JSValue op2);
|
||||
JS_BOOL JS_SameValue (JSContext *ctx, JSValue op1, JSValue op2);
|
||||
|
||||
int JS_ToBool (JSContext *ctx, JSValue val); /* return -1 for JS_EXCEPTION */
|
||||
int JS_ToInt32 (JSContext *ctx, int32_t *pres, JSValue val);
|
||||
|
||||
@@ -1244,15 +1244,16 @@ return {
|
||||
// EDGE CASES AND SPECIAL VALUES
|
||||
// ============================================================================
|
||||
|
||||
test_infinity: function() {
|
||||
test_division_by_zero_is_null: function() {
|
||||
var inf = 1 / 0
|
||||
if (!(inf > 1000000)) throw "infinity failed"
|
||||
if (!(-inf < -1000000)) throw "negative infinity failed"
|
||||
if (inf != null) throw "division by zero should be null"
|
||||
var ninf = -1 / 0
|
||||
if (ninf != null) throw "negative division by zero should be null"
|
||||
},
|
||||
|
||||
test_nan: function() {
|
||||
test_zero_div_zero_is_null: function() {
|
||||
var nan = 0 / 0
|
||||
if (nan == nan) throw "NaN should not equal itself"
|
||||
if (nan != null) throw "0/0 should be null"
|
||||
},
|
||||
|
||||
test_max_safe_integer: function() {
|
||||
@@ -1403,17 +1404,36 @@ return {
|
||||
|
||||
test_number_division_by_zero: function() {
|
||||
var result = 1 / 0
|
||||
if (!(result > 1000000)) throw "division by zero should give infinity"
|
||||
if (result != null) throw "division by zero should give null"
|
||||
},
|
||||
|
||||
test_number_negative_division_by_zero: function() {
|
||||
var result = -1 / 0
|
||||
if (!(result < -1000000)) throw "negative division by zero should give -infinity"
|
||||
if (result != null) throw "negative division by zero should give null"
|
||||
},
|
||||
|
||||
test_zero_division_by_zero: function() {
|
||||
var result = 0 / 0
|
||||
if (result == result) throw "0/0 should give NaN"
|
||||
if (result != null) throw "0/0 should give null"
|
||||
},
|
||||
|
||||
test_negative_zero_normalized: function() {
|
||||
var nz = -0
|
||||
if (nz != 0) throw "-0 should equal 0"
|
||||
var mul_nz = 0 * -1
|
||||
if (mul_nz != 0) throw "0 * -1 should be 0"
|
||||
var neg_zero = -(0)
|
||||
if (neg_zero != 0) throw "-(0) should be 0"
|
||||
},
|
||||
|
||||
test_overflow_is_null: function() {
|
||||
var result = 1e38 * 1e38
|
||||
if (result != null) throw "overflow should give null"
|
||||
},
|
||||
|
||||
test_modulo_by_zero_is_null: function() {
|
||||
var result = 5 % 0
|
||||
if (result != null) throw "modulo by zero should give null"
|
||||
},
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user