http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/core/BinaryDataTesterTest.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/core/BinaryDataTesterTest.as b/manualtests/GenericTests/src/flexUnitTests/core/BinaryDataTesterTest.as deleted file mode 100644 index b10d18c..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/core/BinaryDataTesterTest.as +++ /dev/null @@ -1,567 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.core -{ - - - import org.apache.flex.utils.Endian; - import flexunit.framework.Assert; - import org.apache.flex.utils.BinaryData - - - public class BinaryDataTesterTest - { - - [Before] - public function setUp():void { - } - - [After] - public function tearDown():void { - } - - [BeforeClass] - public static function setUpBeforeClass():void { - } - - [AfterClass] - public static function tearDownAfterClass():void { - } - - - //util check functions - private static function bytesMatchExpectedData(bd:BinaryData,expected:Array,offset:int=0):Boolean{ - var len:uint = expected.length; - var end:uint=offset+len; - for (var i:int=offset;i<end;i++) { - var check:uint = bd.readByteAt(i); - if (expected[i-offset]!=check) { - // trace('failed at ',i,expected[i-offset],check); - return false; - } - } - return true; - } - - private static function reversedBytesMatch(bd1:BinaryData,bd2:BinaryData,len:uint,offset:int=0):Boolean{ - var end:uint=offset+len; - for (var i:int=offset;i<end;i++) { - if (bd1.readByteAt(i) != bd2.readByteAt(end-1-i)) return false; - } - return true; - - } - - - [Test] - public function testBasicPositionAndLength():void - { - var ba:BinaryData = new BinaryData(); - - Assert.assertEquals("new Instance, position", 0, ba.position); - Assert.assertEquals("new Instance, length", 0, ba.length); - - ba.position=100; - Assert.assertEquals("position change, position", 100, ba.position); - Assert.assertEquals("position change, length", 0, ba.length); - Assert.assertEquals("position change, length", 0, ba.bytesAvailable); - - ba.length=100; - Assert.assertEquals("length change, position", 100, ba.position); - Assert.assertEquals("length change, length", 100, ba.length); - - ba.length=50; - Assert.assertEquals("length change, position", 50, ba.position); - Assert.assertEquals("length change, length", 50, ba.length); - - - } - - [Test] - public function testAdvancedPositionAndLength():void - { - var ba:BinaryData = new BinaryData(); - - ba.position=100; - ba.length=100; - - ba.writeByteAt(49,255); - Assert.assertEquals("writeByteAt does not affect position",100, ba.position); - Assert.assertEquals("writeByteAt (internal) does not affect length",100, ba.length); - - ba.readByteAt(48); - Assert.assertEquals("readByteAt does not affect position",100, ba.position); - Assert.assertEquals("readByteAt does not affect length",100, ba.length); - - ba.writeByteAt(199,255); - Assert.assertEquals("writeByteAt (beyond length) does affect length",200, ba.length); - Assert.assertEquals("writeByteAt (beyond length) does not affect position",100, ba.position); - - Assert.assertStrictlyEquals("out of range byte read request",0 ,ba.readByteAt(205)); - - } - - - [Test] - public function testUTFWritePosition():void - { - var ba:BinaryData = new BinaryData(); - ba.writeUTF('This is a test'); - //writeUTF - Assert.assertEquals("basic post-writeUTF position", 16, ba.position); - ba=new BinaryData(); - ba.writeUTFBytes('This is a test'); - //writeUTFBytes - Assert.assertEquals("basic post-writeUTFBytes position", 14, ba.position); - - //overlapping - ba.position=5; - ba.writeUTFBytes('This is a test'); - Assert.assertEquals("Advanced post-writeUTFBytes position (overlap)", 19, ba.position); - - } - - [Test] - public function testBooleanRoundTripping():void - { - var ba:BinaryData = new BinaryData(); - ba.writeBoolean(true); - ba.writeBoolean(false); - ba.position = 0; - Assert.assertTrue(ba.readBoolean()); - Assert.assertFalse(ba.readBoolean()); - } - - [Test] - public function testByteRoundTripping():void - { - var ba:BinaryData = new BinaryData(); - ba.writeByte(255); - ba.writeByte(256); - ba.writeByte(-256); - ba.writeByte(-257); - ba.writeByte(-128); - ba.writeByte(128); - ba.writeByte(127); - ba.writeByte(-50); - ba.writeByte(50); - ba.position = 0; - - - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -1, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 0, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 0, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -1, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -128, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -128, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 127, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -50, ba.readByte()); - Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 50, ba.readByte()); - } - - - [Test] - public function testUnsignedByteRoundTripping():void - { - var ba:BinaryData = new BinaryData(); - ba.writeByte(255); - ba.writeByte(256); - ba.writeByte(-256); - ba.writeByte(-257); - ba.writeByte(-128); - ba.writeByte(128); - ba.writeByte(127); - ba.writeByte(-50); - ba.writeByte(50); - ba.position = 0; - //check read values - - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 255, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 0, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 0, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 255, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 128, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 128, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 127, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 206, ba.readUnsignedByte()); - Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 50, ba.readUnsignedByte()); - } - - - [Test] - public function testBasicEndian():void - { - - var systemEndian:String = Endian.systemEndian; - //check we have a decisive systemEndian detection - Assert.assertNotNull(systemEndian ); - - - var ba:BinaryData = new BinaryData(); - var defaultEndian:String = ba.endian; - - var alternateEndian:String = (defaultEndian == Endian.BIG_ENDIAN) ? Endian.LITTLE_ENDIAN : Endian.BIG_ENDIAN; - var expected:Object ={}; - expected[Endian.BIG_ENDIAN] = 218038271; - expected[Endian.LITTLE_ENDIAN] = 4294966796; - var bytes:Array = [12, 254, 255, 255]; - for each(var byte:uint in bytes) ba.writeByte(byte); - ba.position = 0; - - Assert.assertEquals("testing endian:"+defaultEndian, expected[defaultEndian] , ba.readUnsignedInt()); - - ba.position = 0; - ba.endian = alternateEndian; - var result:uint = ba.readUnsignedInt(); - - Assert.assertEquals("testing endian:"+alternateEndian, expected[alternateEndian], result); - - ba.position = 0; - ba.endian = defaultEndian; - Assert.assertEquals("testing endian:"+defaultEndian, int(expected[defaultEndian]), ba.readInt()); - - ba.position = 0; - ba.endian = alternateEndian; - Assert.assertEquals("testing endian:"+alternateEndian, int(expected[alternateEndian]), ba.readInt()); - - var leBA:BinaryData = new BinaryData(); - leBA.endian = Endian.LITTLE_ENDIAN; - var beBA:BinaryData = new BinaryData(); - beBA.endian = Endian.BIG_ENDIAN; - //int writing - beBA.writeInt(-500); - leBA.writeInt(-500); - //check they represent reversed byte sequence - Assert.assertTrue(reversedBytesMatch(beBA,leBA,4)); - beBA.position=0; - leBA.position=0; - //check they each read back to the same uint value - Assert.assertEquals('big endian',4294966796,beBA.readUnsignedInt()); - Assert.assertEquals('little endian',4294966796,leBA.readUnsignedInt()); - - beBA.position=0; - leBA.position=0; - //uint writing - beBA.writeUnsignedInt(4294966796); - leBA.writeUnsignedInt(4294966796); - //check they represent reversed byte sequence - Assert.assertTrue(reversedBytesMatch(beBA,leBA,4)); - beBA.position=0; - leBA.position=0; - //check they each read back to the same uint value - Assert.assertEquals('big endian',4294966796,beBA.readUnsignedInt()); - Assert.assertEquals('little endian',4294966796,leBA.readUnsignedInt()); - - - beBA.position=0; - leBA.position=0; - - //check they each read back to the same int value - Assert.assertEquals('big endian',-500,beBA.readInt()); - Assert.assertEquals('little endian',-500,leBA.readInt()); - - - beBA.position=0; - leBA.position=0; - - //short writing - beBA.writeShort(-500); - leBA.writeShort(-500); - //check they represent reversed byte sequence - Assert.assertTrue(reversedBytesMatch(beBA,leBA,2)); - beBA.position=0; - leBA.position=0; - //check they each read back to the same uint value - Assert.assertEquals('big endian',65036,beBA.readUnsignedShort()); - Assert.assertEquals('little endian',65036,leBA.readUnsignedShort()); - - - beBA.position=0; - leBA.position=0; - - //check they each read back to the same int value - Assert.assertEquals('big endian',-500,beBA.readShort()); - Assert.assertEquals('little endian',-500,leBA.readShort()); - - } - - - [Test] - public function testUTFRoundtripping():void - { - - //test big-endian round-tripping - var ba:BinaryData = new BinaryData(); - ba.endian = Endian.BIG_ENDIAN; - ba.writeUTF('This is a test'); - //writeUTF - Assert.assertEquals("basic post-writeUTF position", 16, ba.position); - ba.position = 0; - Assert.assertEquals("utf big endian round-tripping", 'This is a test', ba.readUTF()); - - ba = new BinaryData(); - //test little-endian round-tripping - ba.endian = Endian.LITTLE_ENDIAN; - ba.writeUTF('This is a test'); - //writeUTF - Assert.assertEquals("basic post-writeUTF position", 16, ba.position); - ba.position = 0; - Assert.assertEquals("utf big endian round-tripping", 'This is a test', ba.readUTF()); - - } - - - [Test] - public function testShortRoundTripping():void - { - var ba:BinaryData = new BinaryData(); - //test LITTLE_ENDIAN round-tripping - ba.endian = Endian.LITTLE_ENDIAN; - ba.writeShort(255); - ba.writeShort(-50); - ba.writeShort(50); - ba.position = 0; - - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 6, ba.length); - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 255, ba.readShort()); - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", -50, ba.readShort()); - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 50, ba.readShort()); - - //test BIG_ENDIAN round-tripping - - ba.position = 0; - ba.endian = Endian.BIG_ENDIAN ; - ba.writeShort(255); - ba.writeShort(-50); - ba.writeShort(50); - ba.position = 0; - - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 6, ba.length); - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 255, ba.readShort()); - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", -50, ba.readShort()); - Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 50, ba.readShort()); - } - - - [Test] - public function testUnsignedShortRoundTripping():void - { - var ba:BinaryData = new BinaryData(); - //test LITTLE_ENDIAN round-tripping - ba.endian = Endian.LITTLE_ENDIAN; - ba.writeShort(255); - ba.writeShort(-50); - ba.writeShort(50); - ba.position = 0; - - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 6, ba.length); - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 255, ba.readUnsignedShort()); - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 65486, ba.readUnsignedShort()); - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 50, ba.readUnsignedShort()); - - //test BIG_ENDIAN round-tripping - - ba.position = 0; - ba.endian = Endian.BIG_ENDIAN ; - ba.writeShort(255); - ba.writeShort(-50); - ba.writeShort(50); - ba.position = 0; - - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 6, ba.length); - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 255, ba.readUnsignedShort()); - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 65486, ba.readUnsignedShort()); - Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 50, ba.readUnsignedShort()); - } - - [Test] - public function testIntRoundTripping():void - { - var ba:BinaryData = new BinaryData(); - //test LITTLE_ENDIAN round-tripping - ba.endian = Endian.LITTLE_ENDIAN; - ba.writeInt(65536); - ba.writeInt(-50); - ba.writeInt(50); - ba.position = 0; - - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", -50, ba.readInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readInt()); - - //test BIG_ENDIAN round-tripping - - ba.position = 0; - ba.endian = Endian.BIG_ENDIAN ; - ba.writeInt(65536); - ba.writeInt(-50); - ba.writeInt(50); - ba.position = 0; - - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", -50, ba.readInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readInt()); - } - - - [Test] - public function testUnsignedIntRoundTripping():void - { - var ba:BinaryData = new BinaryData(); - //test LITTLE_ENDIAN round-tripping - ba.endian = Endian.LITTLE_ENDIAN; - ba.writeUnsignedInt(65536); - ba.writeUnsignedInt(-50); - ba.writeUnsignedInt(50); - ba.position = 0; - - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping",65536, ba.readUnsignedInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 4294967246, ba.readUnsignedInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readUnsignedInt()); - - //test BIG_ENDIAN round-tripping - - ba.position = 0; - ba.endian = Endian.BIG_ENDIAN ; - ba.writeUnsignedInt(65536); - ba.writeUnsignedInt(-50); - ba.writeUnsignedInt(50); - ba.position = 0; - - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping",65536, ba.readUnsignedInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 4294967246, ba.readUnsignedInt()); - Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readUnsignedInt()); - } - - [Test] - public function testFloatRoundTripping():void - { - var ble:BinaryData = new BinaryData(); - //test LITTLE_ENDIAN round-tripping - ble.endian = Endian.LITTLE_ENDIAN; - ble.writeFloat(86.54); - - - Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, ble.length); - Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, ble.position); - //check bytes to account for precision loss between double and float comparisons - Assert.assertTrue("Error testing post writeFloat/readFloat round-tripping", bytesMatchExpectedData(ble,[123,20,173,66])); - - var bbe:BinaryData = new BinaryData(); - //test BIG_ENDIAN round-tripping - bbe.endian = Endian.BIG_ENDIAN; - bbe.writeFloat(86.54); - - - Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, bbe.length); - Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, bbe.position); - //check bytes to account for precision loss between double and float comparisons - Assert.assertTrue("Error testing post writeFloat/readFloat round-tripping", bytesMatchExpectedData(bbe,[66,173,20,123])); - - - } - - - [Test] - public function testDoubleRoundTripping():void - { - - var ble:BinaryData = new BinaryData(); - //test LITTLE_ENDIAN round-tripping - ble.endian = Endian.LITTLE_ENDIAN; - ble.writeDouble(86.54); - - - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.length); - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.position); - - //check bytes - Assert.assertTrue("Error testing post writeDouble/readDouble round-tripping", bytesMatchExpectedData(ble,[195,245,40,92,143,162,85,64])); - - var bbe:BinaryData = new BinaryData(); - //test BIG_ENDIAN round-tripping - bbe.endian = Endian.BIG_ENDIAN; - bbe.writeDouble(86.54); - - - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.length); - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.position); - //check bytes - - Assert.assertTrue("Error testing post writeDouble/readDouble round-tripping", bytesMatchExpectedData(bbe,[64,85,162,143,92,40,245,195])); - - - ble.position = 0; - bbe.position = 0; - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 86.54, bbe.readDouble()); - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 86.54, ble.readDouble()); - - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.position); - Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.position); - - } - - - - [Test] - public function testWriteBytes():void - { - var ba:BinaryData = new BinaryData(); - for (var i:int=0;i<50;i++) ba.writeByte(i); - - - var newBa:BinaryData = new BinaryData(); - newBa.writeBytes(ba); - - Assert.assertEquals("BinaryData writeBytes: length", 50, newBa.length); - Assert.assertEquals("BinaryData writeBytes: position", 50, newBa.position); - - for (i=0;i<50;i++) { - Assert.assertEquals("BinaryData writeBytes: content check", i, newBa.array[i]); - } - - - - } - - [Test] - public function testReadBytes():void - { - var ba:BinaryData = new BinaryData(); - for (var i:int=0;i<50;i++) ba.writeByte(i); - ba.position=0; - var newBa:BinaryData = new BinaryData(); - - ba.readBytes(newBa,5,10); - Assert.assertEquals("BinaryData readBytes: position", 10, ba.position); - Assert.assertEquals("BinaryData readBytes: length", 15, newBa.length); - Assert.assertEquals("BinaryData readBytes: position", 0, newBa.position); - var expected:Array = [0,0,0,0,0,0,1,2,3,4,5,6,7,8,9]; - for (i=5;i<15;i++) { - Assert.assertEquals("BinaryData readBytes: content check", expected[i], newBa.array[i]); - } - } - - - } -}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/core/StrandTesterTest.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/core/StrandTesterTest.as b/manualtests/GenericTests/src/flexUnitTests/core/StrandTesterTest.as deleted file mode 100644 index f6715bb..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/core/StrandTesterTest.as +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.core -{ - import flexunit.framework.Assert; - - import org.apache.flex.core.Strand; - - public class StrandTesterTest - { - [Before] - public function setUp():void - { - } - - [After] - public function tearDown():void - { - } - - [BeforeClass] - public static function setUpBeforeClass():void - { - } - - [AfterClass] - public static function tearDownAfterClass():void - { - } - - [Test] - public function testIdProperty():void - { - var strand:Strand = new Strand(); - strand.id = "foo"; - Assert.assertEquals("Error testing Srand.id", "foo",strand.id); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/jira/JiraTesterTest.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/jira/JiraTesterTest.as b/manualtests/GenericTests/src/flexUnitTests/jira/JiraTesterTest.as deleted file mode 100644 index c361f39..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/jira/JiraTesterTest.as +++ /dev/null @@ -1,73 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.jira -{ - import flexunit.framework.Assert; - - - public class JiraTesterTest - { - public static var isJS:Boolean; - [BeforeClass] - public static function setUpBeforeClass():void - { - var js:Boolean = false; - try { - var check:* = getDefinitionByName("flash.system.Capabilities"); - } catch (e:Error) { - js = true; - } - //if this next reference to 'check' is not included, then the above try/catch code - // appears to be optimized away in js-release mode - //todo: this is inconsistent with swf, need to create simple test case for jx compiler/gcc - if (check == null) { - js = true; - } - isJS = js; - } - - [AfterClass] - public static function tearDownAfterClass():void - { - } - - - [Before] - public function setUp():void - { - } - - [After] - public function tearDown():void - { - } - - - /* - // TEST METHODS - */ - - //example, postfix the test method with JIRA issue reference: - /*[Test] - public function testJIRA_FLEX_9999():void - { - - }*/ - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/observedbugs/ObservedBugTests.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/observedbugs/ObservedBugTests.as b/manualtests/GenericTests/src/flexUnitTests/observedbugs/ObservedBugTests.as deleted file mode 100644 index 8f3006a..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/observedbugs/ObservedBugTests.as +++ /dev/null @@ -1,101 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.observedbugs -{ - import flexunit.framework.Assert; - import org.apache.flex.reflection.*; - - public class ObservedBugTests - { - - public static var isJS:Boolean; - [BeforeClass] - public static function setUpBeforeClass():void - { - var js:Boolean = false; - try { - var check:* = getDefinitionByName("flash.system.Capabilities"); - } catch (e:Error) { - js = true; - } - //if this next reference to 'check' is not included, then the above try/catch code - // appears to be optimized away in js-release mode - //todo: this is inconsistent with swf, need to create simple test case for jx compiler/gcc - if (check == null) { - js = true; - } - isJS = js; - } - - [AfterClass] - public static function tearDownAfterClass():void - { - } - - [Before] - public function setUp():void - { - } - - [After] - public function tearDown():void - { - } - - - [Test] - public function testTryCatchJSReleaseModeWorks_a():void - { - var js:int = 1; - try { - js = getDefinitionByName("flash.system.Capabilities") != null ? 1 : 0; - } catch (e:Error) { - js = 2; - } - - Assert.assertTrue("Unexpected value following try/catch",(isJS ? (js == 2) : (js == 1))); - - } - - - [TestVariance(variance="JS",description="Variance in test, this test fails in JS-Release mode only")] - [Test] - public function testTryCatchJSReleaseModeFails_b():void - { - var js:Boolean = false; - try { - var check:* = getDefinitionByName("flash.system.Capabilities"); - } catch (e:Error) { - js = true; - } - - //if this next reference to 'check' variable is not included, then the above try/catch code - // appears to be optimized away in js-release mode - //todo: this is inconsistent with swf - /* if (check == null) { - js = true; - }*/ - Assert.assertTrue("Unexpected value following try/catch",(isJS ? (js == true) : (js == false))); - - - } - - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTest.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTest.as b/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTest.as deleted file mode 100644 index 9d39fc9..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTest.as +++ /dev/null @@ -1,373 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection -{ - import flexunit.framework.Assert; - import flexUnitTests.reflection.support.*; - import org.apache.flex.reflection.*; - - public class ReflectionTesterTest - { - - public static var isJS:Boolean; - [BeforeClass] - public static function setUpBeforeClass():void - { - var js:Boolean = false; - try { - var check:* = getDefinitionByName("flash.system.Capabilities"); - } catch (e:Error) { - js = true; - } - //if this next reference to 'check' is not included, then the above try/catch code - //appears to be optimized away in js-release mode - //a separate test has been created for this - if (check == null) { - js = true; - } - isJS = js; - } - - [AfterClass] - public static function tearDownAfterClass():void - { - } - - [Before] - public function setUp():void - { - TestClass2.testStaticVar = "testStaticVar_val"; - TestClass2.testStaticWriteOnly = "staticAccessor_initial_value"; - } - - [After] - public function tearDown():void - { - } - - private static function retrieveItemWithName(collection:Array, name:String):DefinitionBase { - var ret:DefinitionBase; - var i:uint=0,l:uint=collection.length; - for (;i<l;i++) { - if (collection[i].name==name) { - ret = collection[i]; - break; - } - } - - return ret; - } - - - [Test] - public function testBasicDescribeTypeClass():void - { - var def:TypeDefinition = describeType(TestClass2); - - Assert.assertEquals("Unexpected package name",def.packageName,"flexUnitTests.reflection.support"); - Assert.assertEquals("Unexpected type name",def.name,"TestClass2"); - - var variables:Array = def.variables; - Assert.assertEquals("unexpected variables length",1,variables.length); - - - var methods:Array = def.methods; - Assert.assertEquals("unexpected methods length",2,methods.length); - - var accessors:Array = def.accessors; - Assert.assertEquals("unexpected accessors length",3,accessors.length); - - var constructor:MethodDefinition = def.constructorMethod; - Assert.assertEquals("unexpected constructor declaredBy", - "flexUnitTests.reflection.support.TestClass2", - constructor.declaredBy.qualifiedName); - - Assert.assertEquals("unexpected constructor params", - 1, - constructor.parameters.length); - - var meta:Array = def.retrieveMetaDataByName("TestMeta"); - Assert.assertEquals("unexpected class specific meta length", - 1, - meta.length); - - - def = describeType(TestClass4); - Assert.assertEquals("Unexpected package name",def.packageName,"flexUnitTests.reflection.support"); - Assert.assertEquals("Unexpected type name",def.name,"TestClass4"); - - variables = def.variables; - Assert.assertEquals("unexpected variables length",2,variables.length); - - - methods = def.methods; - Assert.assertEquals("unexpected methods length",4,methods.length); - - accessors = def.accessors; - Assert.assertEquals("unexpected accessors length",6,accessors.length); - - constructor = def.constructorMethod; - Assert.assertEquals("unexpected constructor declaredBy", - "flexUnitTests.reflection.support.TestClass4", - constructor.declaredBy.qualifiedName); - - Assert.assertEquals("unexpected constructor params", - 0, - constructor.parameters.length); - - - - } - - - - - [TestVariance(variance="JS",description="Variance in test due to current inability for js target to reflect into non-FlexJS base classes or typedefs")] - [Test] - public function testDescribeTypeClass():void - { - var def:TypeDefinition = describeType(TestClass1); - var expected:*; - Assert.assertEquals("Unexpected package name","flexUnitTests.reflection.support",def.packageName); - Assert.assertEquals("Unexpected type name",def.name,"TestClass1"); - - var variables:Array = def.variables; - Assert.assertEquals("unexpected instance variables length",3,variables.length); - - //there is a difference based on the EventDispatcher inheritance chain differences between js and swf: - expected = isJS ? 4 : 7; - var methods:Array = def.methods; - Assert.assertEquals("unexpected instance methods length",expected,methods.length); - - var accessors:Array = def.accessors; - Assert.assertEquals("unexpected instance accessors length",4,accessors.length); - - var staticVariables:Array =def.staticVariables; - Assert.assertEquals("unexpected static variables length",2,staticVariables.length); - - var staticMethods:Array = def.staticMethods; - Assert.assertEquals("unexpected static methods length",1,staticMethods.length); - //there is a difference based on the native inheritance of readonly 'prototype' not collected from 'Class' (or Object for js): - expected = isJS ? 3 : 4; - var staticAccessors:Array = def.staticAccessors; - Assert.assertEquals("unexpected static accessors length",expected,staticAccessors.length); - - - } - - [TestVariance(variance="JS",description="Variance in test due to current inability for js target to reflect into non-FlexJS base classes or typedefs")] - [Test] - public function testDescribeTypeInstance():void - { - var def:TypeDefinition = describeType(new TestClass1()); - var expected:*; - Assert.assertEquals("Unexpected package name","flexUnitTests.reflection.support",def.packageName); - Assert.assertEquals("Unexpected type name",def.name,"TestClass1"); - - var variables:Array = def.variables; - Assert.assertEquals("unexpected instance variables length",3,variables.length); - - //there is a difference based on the EventDispatcher inheritance chain differences between js and swf: - expected = isJS ? 4 : 7; - var methods:Array = def.methods; - Assert.assertEquals("unexpected instance methods length",expected,methods.length); - - var accessors:Array = def.accessors; - Assert.assertEquals("unexpected instance accessors length",4,accessors.length); - - var staticVariables:Array =def.staticVariables; - Assert.assertEquals("unexpected static variables length",2,staticVariables.length); - - var staticMethods:Array = def.staticMethods; - Assert.assertEquals("unexpected static methods length",1,staticMethods.length); - //there is a difference based on the native inheritance of readonly 'prototype' not collected from 'Class' (or Object for js): - expected = isJS ? 3 : 4; - var staticAccessors:Array = def.staticAccessors; - Assert.assertEquals("unexpected static accessors length",expected,staticAccessors.length); - - - } - - [TestVariance(variance="JS",description="Variance in baseClasses due to current inability for js target to reflect into non-FlexJS base classes or typedefs")] - [Test] - public function testBaseClasses():void{ - var def:TypeDefinition = describeType(TestClass1); - - var baseClasses:Array = def.baseClasses; - var expected:uint = isJS ? 1 : 3; - Assert.assertEquals("unexpected baseclasses length",expected,baseClasses.length); - } - - - [Test] - public function testMemberAccess():void{ - //all of these should succeed without error - var inst:TestClass2 = new TestClass2(""); - var def:TypeDefinition = describeType(inst); - - /** instance variables **/ - - var variables:Array = def.variables; - var variable:VariableDefinition = variables[0]; - Assert.assertEquals("unexpected variable name","testVar",variable.name); - var meta:MetaDataDefinition = variable.retrieveMetaDataByName("TestMeta")[0]; - Assert.assertEquals("unexpected meta name","TestMeta",meta.name); - - var metaArg:MetaDataArgDefinition = meta.getArgsByKey("foo")[0]; - Assert.assertEquals("unexpected meta arg name","foo",metaArg.name); - Assert.assertEquals("unexpected meta arg value","instanceVariable",metaArg.value); - - Assert.assertEquals("unexpected reflection initial variable value","testVar_val",inst[variable.name]); - - var accessors:Array = def.accessors; - var testReadOnly:AccessorDefinition = retrieveItemWithName(accessors,"testReadOnly") as AccessorDefinition; - meta = testReadOnly.retrieveMetaDataByName("TestMeta")[0]; - Assert.assertEquals("unexpected meta name","TestMeta",meta.name); - - metaArg = meta.getArgsByKey("foo")[0]; - Assert.assertEquals("unexpected meta arg name","foo",metaArg.name); - Assert.assertEquals("unexpected meta arg value","instanceAccessor",metaArg.value); - - /** instance accessors **/ - var testWriteOnly:AccessorDefinition = retrieveItemWithName(accessors,"testWriteOnly") as AccessorDefinition; - var testReadWrite:AccessorDefinition = retrieveItemWithName(accessors,"testReadWrite") as AccessorDefinition; - Assert.assertNotNull(testReadOnly); - Assert.assertNotNull(testWriteOnly); - Assert.assertNotNull(testReadWrite); - - Assert.assertEquals("unexpected accessor initial value","instanceAccessor_initial_value",inst[testReadOnly.name]); - Assert.assertEquals("unexpected accessor initial value","instanceAccessor_initial_value",inst[testReadWrite.name]); - - inst[testWriteOnly.name] = "test"; - Assert.assertEquals("unexpected accessor initial value","test",inst[testReadOnly.name]); - Assert.assertEquals("unexpected accessor initial value","test",inst[testReadWrite.name]); - - inst[testReadWrite.name] = "test2"; - Assert.assertEquals("unexpected accessor initial value","test2",inst[testReadOnly.name]); - Assert.assertEquals("unexpected accessor initial value","test2",inst[testReadWrite.name]); - - /** instance methods **/ - var methods:Array = def.methods; - var testMethod:MethodDefinition = retrieveItemWithName(methods,"testMethod") as MethodDefinition; - meta = testMethod.retrieveMetaDataByName("TestMeta")[0]; - Assert.assertEquals("unexpected meta name","TestMeta",meta.name); - - metaArg = meta.getArgsByKey("foo")[0]; - Assert.assertEquals("unexpected meta arg name","foo",metaArg.name); - Assert.assertEquals("unexpected meta arg value","instanceMethod",metaArg.value); - Assert.assertEquals("unexpected parameter count",0,testMethod.parameters.length); - inst[testMethod.name](); - Assert.assertEquals("unexpected method invocation result","testMethod was called",inst[testReadWrite.name]); - - var testMethodWithArgs:MethodDefinition = retrieveItemWithName(methods,"testMethodWithArgs") as MethodDefinition; - Assert.assertEquals("unexpected parameter count",2,testMethodWithArgs.parameters.length); - Assert.assertTrue("unexpected method invocation result",inst[testMethodWithArgs.name]("test")); - Assert.assertFalse("unexpected method invocation result",inst[testMethodWithArgs.name]("test", false)); - Assert.assertEquals("unexpected method invocation result","testMethodWithArgs was called",inst[testReadWrite.name]); - - - - /** static vars **/ - variables = def.staticVariables; - - - variable = variables[0]; - Assert.assertEquals("unexpected variable name","testStaticVar",variable.name); - meta = variable.retrieveMetaDataByName("TestMeta")[0]; - Assert.assertEquals("unexpected meta name","TestMeta",meta.name); - - metaArg = meta.getArgsByKey("foo")[0]; - Assert.assertEquals("unexpected meta arg name","foo",metaArg.name); - Assert.assertEquals("unexpected meta arg value","staticVariable",metaArg.value); - - Assert.assertEquals("unexpected reflection initial variable value","testStaticVar_val",TestClass2[variable.name]); - - /** static accessors **/ - - accessors = def.staticAccessors; - - - testReadOnly = retrieveItemWithName(accessors,"testStaticReadOnly") as AccessorDefinition; - meta = testReadOnly.retrieveMetaDataByName("TestMeta")[0]; - Assert.assertEquals("unexpected meta name","TestMeta",meta.name); - - metaArg = meta.getArgsByKey("foo")[0]; - Assert.assertEquals("unexpected meta arg name","foo",metaArg.name); - Assert.assertEquals("unexpected meta arg value","staticAccessor",metaArg.value); - - - testWriteOnly = retrieveItemWithName(accessors,"testStaticWriteOnly") as AccessorDefinition; - testReadWrite = retrieveItemWithName(accessors,"testStaticReadWrite") as AccessorDefinition; - Assert.assertNotNull(testReadOnly); - Assert.assertNotNull(testWriteOnly); - Assert.assertNotNull(testReadWrite); - - Assert.assertEquals("unexpected accessor initial value","staticAccessor_initial_value",TestClass2[testReadOnly.name]); - Assert.assertEquals("unexpected accessor initial value","staticAccessor_initial_value",TestClass2[testReadWrite.name]); - - TestClass2[testWriteOnly.name] = "test"; - Assert.assertEquals("unexpected accessor initial value","test",TestClass2[testReadOnly.name]); - Assert.assertEquals("unexpected accessor initial value","test",TestClass2[testReadWrite.name]); - - TestClass2[testReadWrite.name] = "test2"; - Assert.assertEquals("unexpected accessor initial value","test2",TestClass2[testReadOnly.name]); - Assert.assertEquals("unexpected accessor initial value","test2",TestClass2[testReadWrite.name]); - - - /** static methods **/ - methods = def.staticMethods; - testMethod = retrieveItemWithName(methods,"testStaticMethod") as MethodDefinition; - meta = testMethod.retrieveMetaDataByName("TestMeta")[0]; - Assert.assertEquals("unexpected meta name","TestMeta",meta.name); - - metaArg = meta.getArgsByKey("foo")[0]; - Assert.assertEquals("unexpected meta arg name","foo",metaArg.name); - Assert.assertEquals("unexpected meta arg value","staticMethod",metaArg.value); - Assert.assertEquals("unexpected parameter count",0,testMethod.parameters.length); - TestClass2[testMethod.name](); - Assert.assertEquals("unexpected method invocation result","testStaticMethod was called",TestClass2[testReadWrite.name]); - - testMethodWithArgs = retrieveItemWithName(methods,"testStaticMethodWithArgs") as MethodDefinition; - Assert.assertEquals("unexpected parameter count",2,testMethodWithArgs.parameters.length); - Assert.assertTrue("unexpected method invocation result",TestClass2[testMethodWithArgs.name]("test")); - Assert.assertFalse("unexpected method invocation result",TestClass2[testMethodWithArgs.name]("test", false)); - Assert.assertEquals("unexpected method invocation result","testStaticMethodWithArgs was called",TestClass2[testReadWrite.name]); - - } - - - [Test] - public function testInterfaceReflection():void{ - var def:TypeDefinition = describeType(ITestInterface4); - Assert.assertEquals("unexpected kind value","interface",def.kind); - Assert.assertEquals("unexpected interfaces length",3,def.interfaces.length); - Assert.assertEquals("unexpected accessors length",1,def.accessors.length); - Assert.assertEquals("unexpected methods length",1,def.methods.length); - - Assert.assertEquals("unexpected variables length",0,def.variables.length); - Assert.assertEquals("unexpected staticVariables length",0,def.staticVariables.length); - Assert.assertEquals("unexpected variables length",0,def.staticMethods.length); - Assert.assertEquals("unexpected staticVariables length",0,def.staticAccessors.length); - Assert.assertNull("unexpected constructor Method definition",def.constructorMethod); - } - - - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestAlias.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestAlias.as b/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestAlias.as deleted file mode 100644 index 7fd5984..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestAlias.as +++ /dev/null @@ -1,90 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection -{ - import flexunit.framework.Assert; - import flexUnitTests.reflection.support.*; - import org.apache.flex.reflection.*; - - public class ReflectionTesterTestAlias - { - - public static var isJS:Boolean; - [BeforeClass] - public static function setUpBeforeClass():void - { - var js:Boolean = false; - try { - var check:* = getDefinitionByName("flash.system.Capabilities"); - } catch (e:Error) { - js = true; - } - //if this next reference to 'check' is not included, then the above try/catch code - //appears to be optimized away in js-release mode - //a separate test has been created for this - if (check == null) { - js = true; - } - isJS = js; - } - - [AfterClass] - public static function tearDownAfterClass():void - { - } - - [Before] - public function setUp():void - { - - } - - [After] - public function tearDown():void - { - - } - - - - - [Test] - public function testBasicAlias():void { - //no initial alias - Assert.assertNull(getAliasByClass(TestClass2)); - registerClassAlias("fjsTest", TestClass2); - //alias is registered - Assert.assertEquals("unexpected Alias value","fjsTest",getAliasByClass(TestClass2)); - //register same alias for another class - registerClassAlias("fjsTest", TestClass3); - //original alias mapping is deregistered - Assert.assertNull(getAliasByClass(TestClass2)); - //alias is registered for new class - Assert.assertEquals("unexpected Alias value","fjsTest",getAliasByClass(TestClass3)); - - //class is retrievable by alias - Assert.assertEquals("unexpected Class value",TestClass3,getClassByAlias("fjsTest")); - - - } - - - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestUseCache.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestUseCache.as b/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestUseCache.as deleted file mode 100644 index 9722647..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/ReflectionTesterTestUseCache.as +++ /dev/null @@ -1,93 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection -{ - import flexunit.framework.Assert; - import flexUnitTests.reflection.support.*; - import org.apache.flex.reflection.*; - - public class ReflectionTesterTestUseCache - { - - public static var isJS:Boolean; - [BeforeClass] - public static function setUpBeforeClass():void - { - var js:Boolean = false; - try { - var check:* = getDefinitionByName("flash.system.Capabilities"); - } catch (e:Error) { - js = true; - } - //if this next reference to 'check' is not included, then the above try/catch code - //appears to be optimized away in js-release mode - //a separate test has been created for this - if (check == null) { - js = true; - } - isJS = js; - } - - [AfterClass] - public static function tearDownAfterClass():void - { - } - - [Before] - public function setUp():void - { - TypeDefinition.useCache = true; - TestClass2.testStaticVar = "testStaticVar_val"; - TestClass2.testStaticWriteOnly = "staticAccessor_initial_value"; - } - - [After] - public function tearDown():void - { - TypeDefinition.useCache = false; - } - - private static function retrieveItemWithName(collection:Array, name:String):DefinitionBase { - var ret:DefinitionBase; - var i:uint=0,l:uint=collection.length; - for (;i<l;i++) { - if (collection[i].name==name) { - ret = collection[i]; - break; - } - } - - return ret; - } - - - [Test] - public function testBasicCache():void { - var def:TypeDefinition = describeType(TestClass2); - - var def2:TypeDefinition = describeType(TestClass2); - - Assert.assertEquals("cache not working",def,def2); - - } - - - - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface.as deleted file mode 100644 index b5a2249..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface.as +++ /dev/null @@ -1,27 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - public interface ITestInterface - { - function someMethod(compulsoryArg:int, optArg:String=null):TestClass1; - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface2.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface2.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface2.as deleted file mode 100644 index f69f9b7..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface2.as +++ /dev/null @@ -1,29 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - public interface ITestInterface2 extends ITestInterface - { - function someMethod2(compulsoryArg:int, optArg:String=null):TestClass1; - - function get someValue2():Boolean; - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface3.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface3.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface3.as deleted file mode 100644 index 83d05ee..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface3.as +++ /dev/null @@ -1,27 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - public interface ITestInterface3 - { - //empty - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface4.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface4.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface4.as deleted file mode 100644 index 7a032f5..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/ITestInterface4.as +++ /dev/null @@ -1,29 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - public interface ITestInterface4 extends ITestInterface2, ITestInterface3 - { - function someMethod3(compulsoryArg:int, optArg:String=null):TestClass1; - - function get someValue3():Boolean; - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass1.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass1.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass1.as deleted file mode 100644 index 76ac834..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass1.as +++ /dev/null @@ -1,91 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - import org.apache.flex.reflection.TypeDefinition; - - [RemoteClass(alias="TestClass1_alias")] - public class TestClass1 implements ITestInterface - { - public function TestClass1() - { - var something:ITestInterface2; - } - - [Bindable] - [Event(name="foo", type="org.apache.flex.events.Event")] - public var bindableVar:String; - [Event(name="foo", type="org.apache.flex.events.Event")] - public var temp:Boolean; - - public static var tempStatic:Boolean; - - public var typeDef:TypeDefinition; - - public var testVar:String="testVar_val"; - - public static var staticTestVar:String="statictestVar_val"; - - private var _atestval:String="accessorTest_val"; - public function get accessorTest():String{ - return _atestval; - } - - public function set accessorTest(val:String):void{ - _atestval = val; - } - - private static var _staticAtestval:String="staticAccessorTest_val"; - public static function get staticAccessorTest():String{ - return _staticAtestval; - } - - public static function set staticAccessorTest(val:String):void{ - _staticAtestval = val; - } - - [Bindable] - public static var bindableStaticVar:String; - - [Bindable] - public var bindableInstanceVar:String; - - - public function someMethod(compulsoryArg:int, optArg:String=null):TestClass1{ - return null; - } - - public static function someStaticMethod(compulsoryArg:int, optArg:String=null):TestClass1{ - return null; - } - - public function get testAccessorType():TypeDefinition { - return null; - } - - public const instanceConstant:String="instanceConstant_val"; - - - public static const staticConstant:String="staticConstant_val"; - - - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as deleted file mode 100644 index bcc7988..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass2.as +++ /dev/null @@ -1,103 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - - [TestMeta(foo="class")] - public class TestClass2 - { - //Note: do not change this test class unless you change the related tests to - //support any changes that might appear when testing reflection into it - - public function TestClass2(blah:String){ - - } - - - [TestMeta(foo="instanceMethod")] - public function testMethod():void{ - _testReadWrite = "testMethod was called"; - } - - [TestMeta(foo="instanceMethod")] - public function testMethodWithArgs(mandatory:String,optional:Boolean=true):Boolean{ - _testReadWrite = "testMethodWithArgs was called"; - return optional; - } - - [TestMeta(foo="instanceVariable")] - public var testVar:String = "testVar_val"; - - [TestMeta(foo="instanceAccessor")] - public function get testReadOnly():String{ - return _testReadWrite - } - - [TestMeta(foo="instanceAccessor")] - public function set testWriteOnly(value:String):void{ - _testReadWrite=value; - } - - [TestMeta(foo="instanceAccessor")] - public function get testReadWrite():String{ - return _testReadWrite - } - public function set testReadWrite(value:String):void{ - _testReadWrite=value; - } - - [TestMeta(foo="staticMethod")] - public static function testStaticMethod():void{ - _testStaticReadWrite = "testStaticMethod was called"; - } - - [TestMeta(foo="staticMethod")] - public static function testStaticMethodWithArgs(mandatory:String,optional:Boolean=true):Boolean{ - _testStaticReadWrite = "testStaticMethodWithArgs was called"; - return optional; - } - - [TestMeta(foo="staticVariable")] - public static var testStaticVar:String = "testStaticVar_val"; - - [TestMeta(foo="staticAccessor")] - public static function get testStaticReadOnly():String{ - return _testStaticReadWrite - } - - [TestMeta(foo="staticAccessor")] - public static function set testStaticWriteOnly(value:String):void{ - _testStaticReadWrite = value; - } - - [TestMeta(foo="staticAccessor")] - public static function get testStaticReadWrite():String{ - return _testStaticReadWrite; - } - public static function set testStaticReadWrite(value:String):void{ - _testStaticReadWrite = value; - } - - - - private static var _testStaticReadWrite:String = "staticAccessor_initial_value"; - private var _testReadWrite:String = "instanceAccessor_initial_value"; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as deleted file mode 100644 index 0b4c59b..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass3.as +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - - - public class TestClass3 extends TestClass1 implements ITestInterface2, ITestInterface3 - { - - public var something:String; - - - public function someMethod2(compulsoryArg:int, optArg:String=null):TestClass1 - { - return null; - } - - public function get someValue2():Boolean { - return false; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as b/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as deleted file mode 100644 index 5d0a28f..0000000 --- a/manualtests/GenericTests/src/flexUnitTests/reflection/support/TestClass4.as +++ /dev/null @@ -1,95 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package flexUnitTests.reflection.support -{ - - - - public class TestClass4 extends TestClass2 - { - //Note: do not change this test class unless you change the related tests to - //support any changes that might appear when testing reflection into it - - public function TestClass4(){ - super(""); - } - - - [TestMeta(foo="instanceMethod")] - public function testMethod2():void{ - - } - - [TestMeta(foo="instanceMethod")] - public function testMethodWithArgs2(mandatory:String,optional:Boolean=true):void{ - - } - - [TestMeta(foo="instanceVariable")] - public var testVar2:String; - - [TestMeta(foo="instanceAccessor")] - public function get testReadonly2():String{ - return null - } - - [TestMeta(foo="instanceAccessor")] - public function set testWriteonly2(value:String):void{ - - } - - [TestMeta(foo="instanceAccessor")] - public function get testReadeWrite2():String{ - return null - } - public function set testReadeWrite2(value:String):void{ - - } - - [TestMeta(foo="staticMethod")] - public static function testStaticMethod():void{ - } - - [TestMeta(foo="staticMethod")] - public static function testStaticMethodWithArgs(mandatory:String,optional:Boolean=true):void{ - } - - [TestMeta(foo="staticVariable")] - public static var testStaticVar:String; - - [TestMeta(foo="staticAccessor")] - public static function get testStaticReadonly():String{ - return null - } - - [TestMeta(foo="staticAccessor")] - public static function set testStaticWriteonly(value:String):void{ - - } - - [TestMeta(foo="staticAccessor")] - public static function get testStaticReadeWrite():String{ - return null - } - public static function set testStaticReadeWrite(value:String):void{ - - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexunit/framework/Assert.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexunit/framework/Assert.as b/manualtests/GenericTests/src/flexunit/framework/Assert.as deleted file mode 100644 index 171f695..0000000 --- a/manualtests/GenericTests/src/flexunit/framework/Assert.as +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package flexunit.framework -{ - //import flexunit.framework.AssertionFailedError; - - /** - * A set of assert methods. Messages are only displayed when an assert fails. - */ - public class Assert - { - /** - * @private - */ - public static var _assertCount:uint = 0; - - /** - * Returns the number of assertions that have been made - */ - public static function get assertionsMade() : uint { - return _assertCount; - } - - - /** - * Resets the count for the number of assertions that have been made back to zero - */ - public static function resetAssertionsFields() : void { - _assertCount = 0; - } - - /** - * @private - */ - public static function assertWithApply( asserter:Function, args:Array ):void { - _assertCount++; - asserter.apply( null, args ); - } - - /** - * @private - */ - public static function assertWith( asserter:Function, ...rest ):void { - _assertCount++; - asserter.apply( null, rest ); - } - - /** - * Asserts that two provided values are equal. - * - * @param asserter The function to use for assertion. - * @param rest - * Must be passed at least 2 arguments of type Object to compare for equality. - * If three arguments are passed, the first argument must be a String - * and will be used as the error message. - * The first of the comparison arguments represents the expected result - * The second is the actual result to compare with the expected result. - * - * <code>assertEquals( String, Object, Object );</code> - * <code>assertEquals( Object, Object );</code> - */ - public static function assertEquals(... rest):void - { - _assertCount++; - if ( rest.length == 3 ) - failNotEquals( rest[0], rest[1], rest[2] ); - else - failNotEquals( "", rest[0], rest[1] ); - } - - /** - * @private - */ - public static function failNotEquals( message:String, expected:Object, actual:Object ):void - { - if ( expected != actual ) - failWithUserMessage( message, "expected:<" + expected + "> but was:<" + actual + ">" ); - } - - /** - * /** - * Asserts that the provided values are strictly equal. - * - * @param rest - * Must be passed at least 2 arguments of type Object to compare for strict equality. - * If three arguments are passed, the first argument must be a String - * and will be used as the error message. - * The first of the comparison arguments represents the expected result - * The second is the actual result to compare with the expected result. - * - * <code>assertStrictlyEquals( String, Object, Object );</code> - * <code>assertStrictlyEquals( Object, Object );</code> - */ - public static function assertStrictlyEquals(... rest):void - { - _assertCount++; - if ( rest.length == 3 ) - failNotStrictlyEquals( rest[0], rest[1], rest[2] ); - else - failNotStrictlyEquals( "", rest[0], rest[1] ); - } - - /** - * @private - */ - public static function failNotStrictlyEquals( message:String, expected:Object, actual:Object ):void - { - if ( expected !== actual ) - failWithUserMessage( message, "expected:<" + expected + "> but was:<" + actual + ">" ); - } - - /** - * Asserts that a condition is true. - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertTrue( String, Boolean );</code> - * <code>assertTrue( Boolean );</code> - */ - public static function assertTrue(... rest):void - { - _assertCount++; - if ( rest.length == 2 ) - failNotTrue( rest[0], rest[1] ); - else - failNotTrue( "", rest[0] ); - } - - /** - * Asserts that a condition is not true. - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertTrue( String, Boolean );</code> - * <code>assertTrue( Boolean );</code> - */ - public static function failNotTrue( message:String, condition:Boolean ):void - { - if ( !condition ) - failWithUserMessage( message, "expected true but was false" ); - } - - /** - * Asserts that a condition is false. - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertFalse( String, Boolean );</code> - * <code>assertFalse( Boolean );</code> - */ - public static function assertFalse(... rest):void - { - _assertCount++; - if ( rest.length == 2 ) - failTrue( rest[0], rest[1] ); - else - failTrue( "", rest[0] ); - } - - /** - * Asserts that a condition is false. - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertTrue( String, Boolean );</code> - * <code>assertTrue( Boolean );</code> - */ - public static function failTrue( message:String, condition:Boolean ):void - { - if ( condition ) - failWithUserMessage( message, "expected false but was true" ); - } - - //TODO: (<code>null</code> okay) needs removal? - /** - * Asserts that an object is null. - * - * @param rest - * Accepts an argument of type Object. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertNull( String, Object );</code> - * <code>assertNull( Object );</code> - * - */ - public static function assertNull(... rest):void - { - _assertCount++; - if ( rest.length == 2 ) - failNotNull( rest[0], rest[1] ); - else - failNotNull( "", rest[0] ); - } - - /** - * Asserts that an object is not null. - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertTrue( String, Boolean );</code> - * <code>assertTrue( Boolean );</code> - */ - public static function failNull( message:String, object:Object ):void - { - if ( object == null ) - failWithUserMessage( message, "object was null: " + object ); - } - - //TODO: (<code>null</code> okay) needs removal? - /** - * Asserts that an object is not null. - * - * @param rest - * Accepts an argument of type Object. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertNotNull( String, Object );</code> - * <code>assertNotNull( Object );</code> - */ - public static function assertNotNull(... rest):void - { - _assertCount++; - if ( rest.length == 2 ) - failNull( rest[0], rest[1] ); - else - failNull( "", rest[0] ); - } - - /** - * Asserts that an object is not null. - * - * @param rest - * Accepts an argument of type Boolean. - * If two arguments are passed the first argument must be a String - * and will be used as the error message. - * - * <code>assertTrue( String, Boolean );</code> - * <code>assertTrue( Boolean );</code> - */ - public static function failNotNull( message:String, object:Object ):void - { - if ( object != null ) - failWithUserMessage( message, "object was not null: " + object ); - } - //TODO: (<code>null</code> okay) needs removal? - /** - * Fails a test with the argument message. - * - * @param failMessage - * the identifying message for the <code> AssertionFailedError</code> (<code>null</code> - * okay) - * @see AssertionFailedError - */ - public static function fail( failMessage:String = ""):void - { - var error:AssertionFailedError = new AssertionFailedError(failMessage); - //this seems necessary for js: - if (error.message!=failMessage) error.message = failMessage; - throw error; - } - - - /** - * @private - */ - private static function failWithUserMessage( userMessage:String, failMessage:String ):void - { - if ( userMessage.length > 0 ) - userMessage = userMessage + " - "; - failMessage = userMessage + failMessage; - fail(failMessage); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/523eac21/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as ---------------------------------------------------------------------- diff --git a/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as b/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as deleted file mode 100644 index 359361f..0000000 --- a/manualtests/GenericTests/src/flexunit/framework/AssertionFailedError.as +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package flexunit.framework -{ - /** - * <code>Error</code> class used for failures in assertions - * - * @see Assert - */ - public class AssertionFailedError extends Error - { - /** - * Throws a new <code>Error</code> of type <code>AssertionError</code> - * with the passed in message - * - * @param message The message associated with the error (<code>null</code> okay) - * @param id The id of the error if desired (<code>null</code> okay) - */ - public function AssertionFailedError(message:String="", id:int=0) - { - super(message, id); - } - - } -} \ No newline at end of file