From 0466605b62609f47f69a2a97b25e2a9b3a37cb64 Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Sun, 10 Mar 2024 13:16:07 +0100 Subject: [PATCH] tests: Test RegExp toString behavior --- tests/tests/swfs/avm2/regexp_toString/Test.as | 28 ++++++++++++++++++ .../swfs/avm2/regexp_toString/output.txt | 10 +++++++ .../tests/swfs/avm2/regexp_toString/test.swf | Bin 0 -> 976 bytes .../tests/swfs/avm2/regexp_toString/test.toml | 1 + 4 files changed, 39 insertions(+) create mode 100644 tests/tests/swfs/avm2/regexp_toString/Test.as create mode 100644 tests/tests/swfs/avm2/regexp_toString/output.txt create mode 100644 tests/tests/swfs/avm2/regexp_toString/test.swf create mode 100644 tests/tests/swfs/avm2/regexp_toString/test.toml diff --git a/tests/tests/swfs/avm2/regexp_toString/Test.as b/tests/tests/swfs/avm2/regexp_toString/Test.as new file mode 100644 index 000000000000..073359431c2c --- /dev/null +++ b/tests/tests/swfs/avm2/regexp_toString/Test.as @@ -0,0 +1,28 @@ +package { + import flash.display.Sprite; + public class Test extends Sprite { + public function Test() { + } + } +} + +var regexp = /abc/xsmig; + +trace("// trace(regexp)"); +trace(regexp); + +trace("// regexp.toString()"); +trace(regexp.toString()); + +trace("// RegExp.prototype.toString.call(regexp)"); +trace(RegExp.prototype.toString.call(regexp)); + +trace("// Object.prototype.toString.call(regexp)"); +trace(Object.prototype.toString.call(regexp)); + +trace("// RegExp.prototype.toString.call({})"); +try { + RegExp.prototype.toString.call({}); +} catch (e) { + trace(e); +} \ No newline at end of file diff --git a/tests/tests/swfs/avm2/regexp_toString/output.txt b/tests/tests/swfs/avm2/regexp_toString/output.txt new file mode 100644 index 000000000000..b22421b0d34b --- /dev/null +++ b/tests/tests/swfs/avm2/regexp_toString/output.txt @@ -0,0 +1,10 @@ +// trace(regexp) +/abc/gimsx +// regexp.toString() +/abc/gimsx +// RegExp.prototype.toString.call(regexp) +/abc/gimsx +// Object.prototype.toString.call(regexp) +[object RegExp] +// RegExp.prototype.toString.call({}) +TypeError: Error #1034: Type Coercion failed: cannot convert Object@00000000000 to RegExp. diff --git a/tests/tests/swfs/avm2/regexp_toString/test.swf b/tests/tests/swfs/avm2/regexp_toString/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..70304373c7714ebc789361ea92f26b35976a3607 GIT binary patch literal 976 zcmV;>126nTS5qbf1^@tf0fkdfZ`(E$Cn?*qocK?g)JeK#bK4Dx+gOsFAz0GXXjV6C z4_$_M#fAccK}(daMV17KjvWlcfPH}7_7(Oqw$lzfEyK_OyYAGZi+zCXkR*HkKO?k+QEP4)A@u$HD~!-i?6}(pt-Z>4;0MVz%pR=vIghptV>BA+ zqYXWbdq#b0Ys)YjMx#*!MJ+iFI33r5Ym+NF4^5L)N5&gR)JU2y1Bx@BF`@up7rqG8wfl0J*i*J+0? zAJG^V42OXuE0xAep|II8qddIQbS@JXp9Z}l?Xe~cI?vlO=LIBpKsjqZqj9Bfu2&jn zWph;ff zV3|tio(7!7)aKq1n;=8GYW6&oX8`;7u(5UPtdFP@cA0L&mUr75M#D5WjqcF%xffI+)pS)o zibEdqPxw&{QdWR>QW@dUMN`2##Y#NtIIlY9-T6!USohT%u7FB{(C8H8mO=ndl zrz$h5GOLojN=n*1R>`8a1n>9M%q?gh0u7UbL6CA2ue|>OUa7#ijWN+uva>KDxP^ho zg@+)xx#B@k~%SAJVlc5Es;in7afy6=jaKB-$KcScteaggtQS8e&b