From cbb2e0e19fba0ad617c45958188d8cd8609ea589 Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Thu, 13 Aug 2026 14:30:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20coercion=5Fconcat/c?= =?UTF-8?q?oercion=5Ftostring/typeof=5Fops=20=E5=8E=8B=E6=B5=8B=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E6=97=A0=E9=99=90=E5=A2=9E=E9=95=BF=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=86=85=E5=AD=98=E8=80=97=E5=B0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/stress/coercion_concat.js | 3 ++- tests/stress/coercion_tostring.js | 3 ++- tests/stress/typeof_ops.js | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/stress/coercion_concat.js b/tests/stress/coercion_concat.js index 4882170..3f3b0d7 100644 --- a/tests/stress/coercion_concat.js +++ b/tests/stress/coercion_concat.js @@ -2,6 +2,7 @@ var ITERATIONS = 100000; var sum = 0; for (var i = 0; i < ITERATIONS; i++) { - sum += "42" + i; + var s = "42" + i; + sum += s.length; } sum diff --git a/tests/stress/coercion_tostring.js b/tests/stress/coercion_tostring.js index 4424baa..40270ae 100644 --- a/tests/stress/coercion_tostring.js +++ b/tests/stress/coercion_tostring.js @@ -2,6 +2,7 @@ var ITERATIONS = 100000; var sum = 0; for (var i = 0; i < ITERATIONS; i++) { - sum += String(42) + String(3.14) + String(0) + String(true) + String(null); + var s = String(42) + String(3.14) + String(0) + String(true) + String(null); + sum += s.length; } sum diff --git a/tests/stress/typeof_ops.js b/tests/stress/typeof_ops.js index b0b489a..c95c654 100644 --- a/tests/stress/typeof_ops.js +++ b/tests/stress/typeof_ops.js @@ -2,9 +2,9 @@ var ITERATIONS = 100000; var sum = 0; for (var i = 0; i < ITERATIONS; i++) { - sum += typeof i; - sum += typeof "str"; - sum += typeof null; - sum += typeof {}.a; + sum += (typeof i).length; + sum += (typeof "str").length; + sum += (typeof null).length; + sum += (typeof {}).length; } sum