Skip to content

Commit

Permalink
tests: Test RegExp toString behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie committed Mar 10, 2024
1 parent 53aee62 commit 0466605
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/tests/swfs/avm2/regexp_toString/Test.as
Original file line number Diff line number Diff line change
@@ -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);
}
10 changes: 10 additions & 0 deletions tests/tests/swfs/avm2/regexp_toString/output.txt
Original file line number Diff line number Diff line change
@@ -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.
Binary file added tests/tests/swfs/avm2/regexp_toString/test.swf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/regexp_toString/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit 0466605

Please sign in to comment.