You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2017/11/08 22:25:55 UTC
[royale-asjs] branch feature/testing updated: A bit more on testing
This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch feature/testing
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/feature/testing by this push:
new 088c59b A bit more on testing
088c59b is described below
commit 088c59bf8f951d1e3a57f8fbd561a499cffa58ae
Author: Harbs <ha...@in-tools.com>
AuthorDate: Thu Nov 9 00:25:50 2017 +0200
A bit more on testing
---
.../apache/royale/test/asserts/assertNotEquals.as | 53 ++++++++
.../royale/test/asserts/assertNotStrictlyEquals.as | 54 ++++++++
.../projects/Testing/src/test/royale/NodeTests.as | 1 +
.../Testing/src/test/royale/tests/AssertTests.as | 136 +++++++++++++++++++++
4 files changed, 244 insertions(+)
diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as
new file mode 100644
index 0000000..bceaefa
--- /dev/null
+++ b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotEquals.as
@@ -0,0 +1,53 @@
+/*
+ * 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 {
+ COMPILE::SWF
+ {
+ import org.flexunit.Assert;
+ }
+
+ COMPILE::JS
+ {
+ import org.apache.royale.test.Assert;
+ }
+
+ /**
+ * Alias for org.flexunit.Assert assertEquals method
+ *
+ * @param rest
+ * Must be passed at least 2 arguments to compare for equality.
+ * If three arguments are passed, the third argument will be used as the error message.
+ *
+ * <code>assertEquals( String, Object, Object );</code>
+ * <code>assertEquals( Object, Object );</code>
+ *
+ * @see org.flexunit.Assert assertEquals
+ */
+ public function assertNotEquals(actual:*, expected:*, message:String = null):void {
+ COMPILE::SWF
+ {
+ if(message)
+ Assert.assertTrue(message, actual != expected);
+ else
+ Assert.assertTrue(actual != expected);
+ }
+ COMPILE::JS
+ {
+ Assert.notEqual(actual, expected, message);
+ }
+ }
+}
\ No newline at end of file
diff --git a/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as
new file mode 100644
index 0000000..1243a05
--- /dev/null
+++ b/frameworks/projects/Testing/src/main/royale/org/apache/royale/test/asserts/assertNotStrictlyEquals.as
@@ -0,0 +1,54 @@
+/*
+ * 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
+{
+ COMPILE::SWF
+ {
+ import org.flexunit.Assert;
+ }
+
+ COMPILE::JS
+ {
+ import org.apache.royale.test.Assert;
+ }
+
+ /**
+ * Alias for org.flexunit.Assert assertStrictlyEquals method
+ *
+ * @param rest
+ * Must be passed at least 2 arguments of type Object to compare for strict equality.
+ * If three arguments are passed, the last argument will be used as the error message.
+ *
+ * <code>assertStrictlyEquals( Object, Object, String );</code>
+ * <code>assertStrictlyEquals( Object, Object );</code>
+ *
+ * @see org.flexunit.Assert assertStrictlyEquals
+ */
+ public function assertNotStrictlyEquals(actual:*, expected:*, message:String = null):void {
+ COMPILE::SWF
+ {
+ if(message)
+ Assert.assertTrue(message, actual !== expected);
+ else
+ Assert.assertTrue(actual !== expected);
+ }
+ COMPILE::JS
+ {
+ Assert.notStrictEqual(actual, expected, message);
+ }
+ }
+}
\ No newline at end of file
diff --git a/frameworks/projects/Testing/src/test/royale/NodeTests.as b/frameworks/projects/Testing/src/test/royale/NodeTests.as
index 0704bd6..a5204a2 100644
--- a/frameworks/projects/Testing/src/test/royale/NodeTests.as
+++ b/frameworks/projects/Testing/src/test/royale/NodeTests.as
@@ -18,6 +18,7 @@ package
[
DetectMetadataTests,
ScopeTests,
+ AssertTests
]);
}
diff --git a/frameworks/projects/Testing/src/test/royale/tests/AssertTests.as b/frameworks/projects/Testing/src/test/royale/tests/AssertTests.as
new file mode 100644
index 0000000..6d1109d
--- /dev/null
+++ b/frameworks/projects/Testing/src/test/royale/tests/AssertTests.as
@@ -0,0 +1,136 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 tests
+{
+ import org.apache.royale.test.asserts.*;
+
+ public class ScopeTests
+ {
+ private var _value:String = "hello";
+
+ [Before]
+ public function prepare():void
+ {
+ Assert.strictEqual(this._value, "hello",
+ "Function marked with [Before] metadata called with incorrect scope.");
+ }
+
+ [After]
+ public function cleanup():void
+ {
+ Assert.strictEqual(this._value, "hello",
+ "Function marked with [After] metadata called with incorrect scope.");
+ }
+
+ [Test]
+ public function testScope():void
+ {
+ Assert.strictEqual(this._value, "hello",
+ "Function marked with [Test] metadata called with incorrect scope.");
+ }
+
+ [Test]
+ public function testAssertDefined():void
+ {
+ var foo:String = "";
+ assertDefined(foo);
+ var baz:Boolean = false;
+ assertDefined(baz);
+ baz = true;
+ assertDefined(baz);
+ }
+
+ [Test]
+ public function testAssertEquals():void
+ {
+ var foo:String = "";
+ var baz:String = "";
+ assertEquals(foo,baz);
+ var bVal1:Boolean = true;
+ var bVal2:Boolean = true;
+ assertEquals(bVal1,bVal2);
+ bVal1 = false;
+ assertEquals(baz,bVal1);
+ foo = baz = "foo";
+ assertEquals(foo,baz);
+ }
+
+ [Test]
+ public function testAssertFalse():void
+ {
+ var foo:String = "";
+ var baz:String = "";
+ assertFalse(foo != baz);
+ var bVal1:Boolean = true;
+ var bVal2:Boolean = true;
+ assertFalse(bVal1 != bVal2);
+ bVal1 = false;
+ assertFalse(baz != bVal1);
+ foo = baz = "foo";
+ assertFalse(foo != baz);
+ }
+
+ [Test]
+ public function testAssertEquals():void
+ {
+ var foo:String = "";
+ var baz:String = "";
+ assertEquals(foo,baz);
+ var bVal1:Boolean = true;
+ var bVal2:Boolean = true;
+ assertEquals(bVal1,bVal2);
+ bVal1 = false;
+ assertEquals(baz,bVal1);
+ foo = baz = "foo";
+ assertEquals(foo,baz);
+ }
+
+ [Test]
+ public function testAssertNotEquals():void
+ {
+ var foo:String = "";
+ var baz:String = "1";
+ assertNotEquals(foo,baz);
+ var bVal1:Boolean = true;
+ var bVal2:Boolean = false;
+ assertNotEquals(bVal1,bVal2);
+ assertNotEquals(baz,bVal2);
+ }
+
+ [Test]
+ public function testAssertNotNull():void
+ {
+ var foo:String = "";
+ var baz:String = "1";
+ assertNotNull(foo);
+ assertNotNull(baz;
+ var bVal1:Boolean = true;
+ var bVal2:Boolean = false;
+ assertNotNull(bVal1);
+ assertNotNull(bVal2);
+ }
+
+// assertNotStrictlyEquals.as
+// assertNull.as
+// assertStrictlyEquals.as
+// assertTrue.as
+// assertUndefined.as
+// fail.as
+ }
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
['"commits@royale.apache.org" <co...@royale.apache.org>'].