You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2019/08/07 06:08:52 UTC

[royale-asjs] 02/04: Adding a compatibility package to manualtests/UnitTests to permit greater alignment of test code assertions with RoyaleUnit

This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 722be262cc6768fa0dc389a1514444ac8b4e920f
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Aug 7 09:32:25 2019 +1200

    Adding a compatibility package to manualtests/UnitTests to permit greater alignment of test code assertions with RoyaleUnit
---
 .../src/main/royale/flexunit/framework/Assert.as   | 53 ++++++++++++++++++++++
 .../org/apache/royale/test/asserts/assertEquals.as | 33 ++++++++++++++
 .../org/apache/royale/test/asserts/assertFalse.as  | 33 ++++++++++++++
 .../apache/royale/test/asserts/assertNotEquals.as  | 33 ++++++++++++++
 .../apache/royale/test/asserts/assertNotNull.as    | 33 ++++++++++++++
 .../royale/test/asserts/assertNotStrictlyEquals.as | 33 ++++++++++++++
 .../org/apache/royale/test/asserts/assertNull.as   | 33 ++++++++++++++
 .../royale/test/asserts/assertStrictlyEquals.as    | 33 ++++++++++++++
 .../org/apache/royale/test/asserts/assertTrue.as   | 33 ++++++++++++++
 .../royale/org/apache/royale/test/asserts/fail.as  | 31 +++++++++++++
 10 files changed, 348 insertions(+)

diff --git a/manualtests/UnitTests/src/main/royale/flexunit/framework/Assert.as b/manualtests/UnitTests/src/main/royale/flexunit/framework/Assert.as
index 6702f62..8c9d258 100644
--- a/manualtests/UnitTests/src/main/royale/flexunit/framework/Assert.as
+++ b/manualtests/UnitTests/src/main/royale/flexunit/framework/Assert.as
@@ -82,6 +82,20 @@ package flexunit.framework
 			else
 				failNotEquals( "", rest[0], rest[1] );
 		}
+		
+		/**
+		 * Asserts that the provided values are not loosely equal (equivalent to
+		 * the <code>!=</code> operator).
+		 */
+		public static function assertNotEquals(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 3 )
+				failEquals( rest[0], rest[1], rest[2] );
+			else
+				failEquals( "", rest[0], rest[1] );
+		}
+		
 	
         /**
          * @private
@@ -91,6 +105,19 @@ package flexunit.framework
 			if ( expected != actual )
 			   failWithUserMessage( message, "expected:<" + expected + "> but was:<" + actual + ">" );
 		}
+		
+		
+		/**
+		 * Fails if the values are loosely equal.
+		 * @private
+		 */
+		public static function failEquals(message:String, expected:Object, actual:Object):void
+		{
+			if(actual == expected)
+			{
+				failWithUserMessage(message,"expected: <" + expected + "> not to be equal to <" + actual + ">");
+			}
+		}
 	
 		/**
 		 * /**
@@ -114,6 +141,32 @@ package flexunit.framework
 			else
 				failNotStrictlyEquals( "", rest[0], rest[1] );
 		}
+		
+		/**
+		 * Asserts that the provided values are not strictly equal (equivalent
+		 * to the <code>!==</code> operator).
+		 */
+		public static function assertNotStrictlyEquals(... rest):void
+		{
+			_assertCount++;
+			if ( rest.length == 3 )
+				failStrictlyEquals( rest[0], rest[1], rest[2] );
+			else
+				failStrictlyEquals( "", rest[0], rest[1] );
+			
+		}
+		
+		
+		/**
+		 * Fails if the values are strictly equal.
+		 */
+		public static function failStrictlyEquals(message:String, expected:Object, actual:Object):void
+		{
+			if(actual === expected)
+			{
+				failWithUserMessage(message,"expected: <" + expected + "> not to be strictly equal to <" + actual + ">");
+			}
+		}
 	
         /**
          * @private
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertEquals.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertEquals.as
new file mode 100644
index 0000000..76f3f63
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertEquals.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert assertEquals method
+	 */
+	public function assertEquals(actual:*, expected:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertEquals(message,actual, expected);
+		else Assert.assertEquals(actual, expected);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertFalse.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertFalse.as
new file mode 100644
index 0000000..9518425
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertFalse.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert assertFalse method
+	 */
+	public function assertFalse(condition:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertFalse(message, condition);
+		else Assert.assertFalse(condition);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as
new file mode 100644
index 0000000..a026bb4
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for org.apache.royale.test.Assert assertNotEquals method
+	 */
+	public function assertNotEquals(actual:*, expected:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertNotEquals(message,actual, expected);
+		else Assert.assertNotEquals(actual, expected);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as
new file mode 100644
index 0000000..b1d884e
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotNull.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert assertNotNull method
+	 */
+	public function assertNotNull(value:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertNotNull(message, value);
+		else Assert.assertNotNull(value);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as
new file mode 100644
index 0000000..e644ef1
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+	
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert assertNotStrictlyEquals method
+	 */
+	public function assertNotStrictlyEquals(actual:*, expected:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertNotStrictlyEquals(message, actual, expected);
+		else Assert.assertNotStrictlyEquals(actual, expected);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNull.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNull.as
new file mode 100644
index 0000000..7e4907e
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertNull.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+	
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert  assertNull method
+	 */
+	public function assertNull(value:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertNull(message, value);
+		else Assert.assertNull(value);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as
new file mode 100644
index 0000000..6c85574
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertStrictlyEquals.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+	
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert assertStrictlyEquals method
+	 */
+	public function assertStrictlyEquals(actual:*, expected:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertStrictlyEquals(message, actual, expected);
+		else Assert.assertStrictlyEquals(actual, expected);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertTrue.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertTrue.as
new file mode 100644
index 0000000..80b563d
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/assertTrue.as
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+	
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert assertTrue method
+	 */
+	public function assertTrue(condition:*, message:String = null):void
+	{
+		if (message)
+			Assert.assertTrue(message, condition);
+		else Assert.assertTrue(condition);
+	}
+}
diff --git a/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/fail.as b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/fail.as
new file mode 100644
index 0000000..7c7b93d
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/org/apache/royale/test/asserts/fail.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.asserts
+{
+	import flexunit.framework.Assert;
+	
+	/**
+	 * RoyaleUnit compatibility
+	 * Alias for flexunit.framework.Assert fail method
+	 */
+	public function fail(message:String = null):void
+	{
+		Assert.fail(message);
+	}
+}