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

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

commit 34f67f776f11c5bc710e4e11ba6a1c775a63471b
Author: greg-dove <[email protected]>
AuthorDate: Tue Apr 21 17:01:41 2026 +1200

    adding 'assertCloseTo' convenience assertion
---
 .../src/main/royale/RoyaleUnitClasses.as           |  1 +
 .../apache/royale/test/asserts/assertCloseTo.as    | 36 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git 
a/frameworks/projects/RoyaleUnit/src/main/royale/RoyaleUnitClasses.as 
b/frameworks/projects/RoyaleUnit/src/main/royale/RoyaleUnitClasses.as
index d1e8c8c6b1..cde3e7d05f 100644
--- a/frameworks/projects/RoyaleUnit/src/main/royale/RoyaleUnitClasses.as
+++ b/frameworks/projects/RoyaleUnit/src/main/royale/RoyaleUnitClasses.as
@@ -29,6 +29,7 @@ internal class RoyaleUnitClasses
        import org.apache.royale.test.Assert;Assert;
        import org.apache.royale.test.AssertionError;AssertionError;
        import org.apache.royale.test.RoyaleUnitCore;RoyaleUnitCore;
+       import org.apache.royale.test.asserts.assertCloseTo;assertCloseTo;
        import org.apache.royale.test.asserts.assertEquals;assertEquals;
        import org.apache.royale.test.asserts.assertFalse;assertFalse;
        import org.apache.royale.test.asserts.assertNotEquals;assertNotEquals;
diff --git 
a/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertCloseTo.as
 
b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertCloseTo.as
new file mode 100644
index 0000000000..c5e13f7f98
--- /dev/null
+++ 
b/frameworks/projects/RoyaleUnit/src/main/royale/org/apache/royale/test/asserts/assertCloseTo.as
@@ -0,0 +1,36 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.test.Assert;
+       
+       /**
+        * convenience assertion that a test value is within an expected 
tolerance (closeness) of an expected value
+        * @param actual
+        * @param target
+        * @param tolerance
+        * @param message
+        */
+       public function assertCloseTo(actual:Number, expected:Number, 
tolerance:Number, message:String = null):void
+       {
+               //just in case
+               tolerance = Math.abs(tolerance);
+               Assert.assertWithin(actual, expected-tolerance, 
expected+tolerance, message);
+       }
+}
\ No newline at end of file

Reply via email to