Skip to content

Commit

Permalink
avm2: Add test for instantiating abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian17 committed Nov 19, 2024
1 parent cd5ac58 commit 580a149
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/tests/swfs/avm2/abstract_classes/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// compiled with mxmlc

import flash.display.*;
import flash.text.engine.TextLine;
import flash.system.Worker;

package {
import flash.display.MovieClip;
public class Test extends MovieClip {
public function Test() {
var classes = [
Stage,
DisplayObject,
DisplayObjectContainer,
InteractiveObject,
LoaderInfo,
TextLine,
Class,
Math,
MorphShape,
Worker,
]
for each(var t in classes) {
trace(t);
try {
new t();
} catch(e) {
trace(e.getStackTrace());
}
}
}
}
}
30 changes: 30 additions & 0 deletions tests/tests/swfs/avm2/abstract_classes/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[class Stage]
ArgumentError: Error #2012: Stage$ class cannot be instantiated.
at Test()
[class DisplayObject]
ArgumentError: Error #2012: DisplayObject$ class cannot be instantiated.
at Test()
[class DisplayObjectContainer]
ArgumentError: Error #2012: DisplayObjectContainer$ class cannot be instantiated.
at Test()
[class InteractiveObject]
ArgumentError: Error #2012: InteractiveObject$ class cannot be instantiated.
at Test()
[class LoaderInfo]
ArgumentError: Error #2012: LoaderInfo$ class cannot be instantiated.
at Test()
[class TextLine]
ArgumentError: Error #2012: TextLine$ class cannot be instantiated.
at Test()
[class Class]
TypeError: Error #1115: Class$ is not a constructor.
at Test()
[class Math]
TypeError: Error #1076: Math is not a constructor.
at Test()
[class MorphShape]
ArgumentError: Error #2012: MorphShape$ class cannot be instantiated.
at Test()
[class Worker]
ArgumentError: Error #2012: Worker$ class cannot be instantiated.
at Test()
Binary file added tests/tests/swfs/avm2/abstract_classes/test.swf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/abstract_classes/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_frames = 1

0 comments on commit 580a149

Please sign in to comment.