From 5650624822cac9dc9ac40990d1c65b4f42182996 Mon Sep 17 00:00:00 2001 From: Benjamin Sinkula Date: Tue, 13 Oct 2020 13:31:22 -0500 Subject: [PATCH] Add ActionScript 3 syntax test --- .../highlighted/ActionScript/test.as | 75 +++++++++++++++++++ .../syntax-tests/source/ActionScript/test.as | 75 +++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 tests/syntax-tests/highlighted/ActionScript/test.as create mode 100644 tests/syntax-tests/source/ActionScript/test.as diff --git a/tests/syntax-tests/highlighted/ActionScript/test.as b/tests/syntax-tests/highlighted/ActionScript/test.as new file mode 100644 index 00000000..2078c571 --- /dev/null +++ b/tests/syntax-tests/highlighted/ActionScript/test.as @@ -0,0 +1,75 @@ +import flash.events.*; +import flash.events.MouseEvent; + +package TestSyntax { + public class TestSyntax extends flash.display.Sprite { + + public static const TEST_CONSTANT:Number = 33.333; + + var testAttribute:int = 1; + + public namespace TestNamespace; + TestNamespace function Method2():void { } + + /** + * Multi-line comment + */ + override public function set x(value:Number):void + { + super.x = Math.round(value); + } + + /** + * Actual multi-line comment + * Takes up multiple lines + */ + override public function set y(value:Number):void + { + super.y = 0; + } + + public function testFunction() { + var test:String = 'hello'; + + // arrays + var testArray:Array = ["a", "b", "c", "d"]; + for (var i:uint = 0; i < testArray.length; i++) + trace(testArray[i]); + + // objects + var testObject:Object = {foo: 20, bar: 40}; + for (var key:String in testObject) { + trace(testObject[key]); + } + for each (var objectValue:int in testObject) { + trace(objectValue); + } + + // dynamic variables + var testDynamic:*; + testDynamic = 75; + testDynamic = "Seventy-five"; + + // regex + var testRegExp:RegExp = /foo-\d+/i; + + // XML + var testXML:XML = + + Harold</firstName> + Webster</lastName> +</employee>; + } + + private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) { + + } + + [Embed(source="sound1.mp3")] public var soundCls:Class; + public function SoundAssetExample() + { + var mySound:SoundAsset = new soundCls() as SoundAsset; + var sndChannel:SoundChannel = mySound.play(); + } + } +} diff --git a/tests/syntax-tests/source/ActionScript/test.as b/tests/syntax-tests/source/ActionScript/test.as new file mode 100644 index 00000000..1f7a1936 --- /dev/null +++ b/tests/syntax-tests/source/ActionScript/test.as @@ -0,0 +1,75 @@ +import flash.events.*; +import flash.events.MouseEvent; + +package TestSyntax { + public class TestSyntax extends flash.display.Sprite { + + public static const TEST_CONSTANT:Number = 33.333; + + var testAttribute:int = 1; + + public namespace TestNamespace; + TestNamespace function Method2():void { } + + /** + * Multi-line comment + */ + override public function set x(value:Number):void + { + super.x = Math.round(value); + } + + /** + * Actual multi-line comment + * Takes up multiple lines + */ + override public function set y(value:Number):void + { + super.y = 0; + } + + public function testFunction() { + var test:String = 'hello'; + + // arrays + var testArray:Array = ["a", "b", "c", "d"]; + for (var i:uint = 0; i < testArray.length; i++) + trace(testArray[i]); + + // objects + var testObject:Object = {foo: 20, bar: 40}; + for (var key:String in testObject) { + trace(testObject[key]); + } + for each (var objectValue:int in testObject) { + trace(objectValue); + } + + // dynamic variables + var testDynamic:*; + testDynamic = 75; + testDynamic = "Seventy-five"; + + // regex + var testRegExp:RegExp = /foo-\d+/i; + + // XML + var testXML:XML = + + Harold + Webster +; + } + + private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) { + + } + + [Embed(source="sound1.mp3")] public var soundCls:Class; + public function SoundAssetExample() + { + var mySound:SoundAsset = new soundCls() as SoundAsset; + var sndChannel:SoundChannel = mySound.play(); + } + } +} \ No newline at end of file