From db3ef449fc97684925991b0bfb0f4c377f2ac1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=89=AF=E4=BB=94?= <32487868+cijiugechu@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:44:03 +0800 Subject: [PATCH] test(minifier): add tests for bigint string comparison (#541) --- .../tests/closure/fold_constants.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/oxc_minifier/tests/closure/fold_constants.rs b/crates/oxc_minifier/tests/closure/fold_constants.rs index 71524e91d..ba76c1bd4 100644 --- a/crates/oxc_minifier/tests/closure/fold_constants.rs +++ b/crates/oxc_minifier/tests/closure/fold_constants.rs @@ -229,6 +229,30 @@ fn test_bigint_number_comparison() { test_wcb("1n > null", "true"); } +#[test] +fn test_bigint_string_comparison() { + test_wcb("1n < '2'", "true"); + test_wcb("2n > '1'", "true"); + test_wcb("123n > '34'", "true"); + test_wcb("1n == '1'", "true"); + test_wcb("1n == '2'", "false"); + test_wcb("1n != '1'", "false"); + test_wcb("1n === '1'", "false"); + test_wcb("1n !== '1'", "true"); +} + +#[test] +fn test_string_bigint_comparison() { + test_wcb("'1' < 2n", "true"); + test_wcb("'2' > 1n", "true"); + test_wcb("'123' > 34n", "true"); + test_wcb("'1' == 1n", "true"); + test_wcb("'1' == 2n", "false"); + test_wcb("'1' != 1n", "false"); + test_wcb("'1' === 1n", "false"); + test_wcb("'1' !== 1n", "true"); +} + #[test] fn js_typeof() { test("x = typeof 1", "x='number'");