on master help sign in
Add ActionScript 3 syntax test
commit5650624822cac9dc9ac40990d1c65b4f42182996 authorBenjamin Sinkula <bsinky@gmail.com> dateTue 13 Oct 2020, 13:31 (6 years ago) parentbf07b0b
2 files changed+150
tests/syntax-tests/highlighted/ActionScript/test.as+75 tests/syntax-tests/source/ActionScript/test.as+75
tests/syntax-tests/highlighted/ActionScript/test.asnew file+75
@@ -0,0 +1,75 @@
1+import flash.events.*;
2+import flash.events.MouseEvent;
3+
4+package TestSyntax {
5+ public class TestSyntax extends flash.display.Sprite {
6+
7+ public static const TEST_CONSTANT:Number = 33.333;
8+
9+ var testAttribute:int = 1;
10+
11+ public namespace TestNamespace;
12+ TestNamespace function Method2():void { }
13+
14+ /**
15+ * Multi-line comment
16+ */
17+ override public function set x(value:Number):void
18+ {
19+ super.x = Math.round(value);
20+ }
21+
22+ /**
23+ * Actual multi-line comment
24+ * Takes up multiple lines
25+ */
26+ override public function set y(value:Number):void
27+ {
28+ super.y = 0;
29+ }
30+
31+ public function testFunction() {
32+ var test:String = 'hello';
33+
34+ // arrays
35+ var testArray:Array = ["a", "b", "c", "d"];
36+ for (var i:uint = 0; i < testArray.length; i++)
37+ trace(testArray[i]);
38+
39+ // objects
40+ var testObject:Object = {foo: 20, bar: 40};
41+ for (var key:String in testObject) {
42+ trace(testObject[key]);
43+ }
44+ for each (var objectValue:int in testObject) {
45+ trace(objectValue);
46+ }
47+
48+ // dynamic variables
49+ var testDynamic:*;
50+ testDynamic = 75;
51+ testDynamic = "Seventy-five";
52+
53+ // regex
54+ var testRegExp:RegExp = /foo-\d+/i;
55+
56+ // XML
57+ var testXML:XML =
58+<employee>
59+ <firstName>Harold</firstName>
60+ <lastName>Webster</lastName>
61+</employee>;
62+ }
63+
64+ private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) {
65+
66+ }
67+
68+ [Embed(source="sound1.mp3")] public var soundCls:Class;
69+ public function SoundAssetExample()
70+ {
71+ var mySound:SoundAsset = new soundCls() as SoundAsset;
72+ var sndChannel:SoundChannel = mySound.play();
73+ }
74+ }
75+}
tests/syntax-tests/source/ActionScript/test.asnew file+75
@@ -0,0 +1,75 @@
1+import flash.events.*;
2+import flash.events.MouseEvent;
3+
4+package TestSyntax {
5+ public class TestSyntax extends flash.display.Sprite {
6+
7+ public static const TEST_CONSTANT:Number = 33.333;
8+
9+ var testAttribute:int = 1;
10+
11+ public namespace TestNamespace;
12+ TestNamespace function Method2():void { }
13+
14+ /**
15+ * Multi-line comment
16+ */
17+ override public function set x(value:Number):void
18+ {
19+ super.x = Math.round(value);
20+ }
21+
22+ /**
23+ * Actual multi-line comment
24+ * Takes up multiple lines
25+ */
26+ override public function set y(value:Number):void
27+ {
28+ super.y = 0;
29+ }
30+
31+ public function testFunction() {
32+ var test:String = 'hello';
33+
34+ // arrays
35+ var testArray:Array = ["a", "b", "c", "d"];
36+ for (var i:uint = 0; i < testArray.length; i++)
37+ trace(testArray[i]);
38+
39+ // objects
40+ var testObject:Object = {foo: 20, bar: 40};
41+ for (var key:String in testObject) {
42+ trace(testObject[key]);
43+ }
44+ for each (var objectValue:int in testObject) {
45+ trace(objectValue);
46+ }
47+
48+ // dynamic variables
49+ var testDynamic:*;
50+ testDynamic = 75;
51+ testDynamic = "Seventy-five";
52+
53+ // regex
54+ var testRegExp:RegExp = /foo-\d+/i;
55+
56+ // XML
57+ var testXML:XML =
58+<employee>
59+ <firstName>Harold</firstName>
60+ <lastName>Webster</lastName>
61+</employee>;
62+ }
63+
64+ private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) {
65+
66+ }
67+
68+ [Embed(source="sound1.mp3")] public var soundCls:Class;
69+ public function SoundAssetExample()
70+ {
71+ var mySound:SoundAsset = new soundCls() as SoundAsset;
72+ var sndChannel:SoundChannel = mySound.play();
73+ }
74+ }
75+}