/* ----------------------------------------------------------------------------- Copyright 2020-2021 Kevin P. Barry Licensed 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. ----------------------------------------------------------------------------- */ // Author: Kevin P. Barry [ta0kira@gmail.com] $TestsOnly$ // General helpers for use in unit tests. concrete Testing { // Check the values for equality. Crashes if they are not equal. // // Args: // - #x: Actual value. // - #x: Expected value. @type checkEquals<#x> #x requires Formatted #x defines Equals<#x> (#x,#x) -> () // Check the values for inequality. Crashes if they are equal. // // Args: // - #x: Actual value. // - #x: Expected value. @type checkNotEquals<#x> #x requires Formatted #x defines Equals<#x> (#x,#x) -> () // Check the value for empty. Crashes if present. // // Args: // - #x: Actual value. @type checkEmpty<#x> (optional #x) -> () // Check the value for present. Crashes if empty. // // Args: // - optional any: Actual value. @type checkPresent (optional any) -> () // Check the optional values for equality. Crashes if they are not equal. // // Args: // - optional #x: Actual value. // - optional #x: Expected value. @type checkOptional<#x> #x requires Formatted #x defines Equals<#x> (optional #x,optional #x) -> () // Check the value for true. Crashes if false. // // Args: // - AsBool: Actual value. @type checkTrue (AsBool) -> () // Check the value for false. Crashes if true. // // Args: // - AsBool: Actual value. @type checkFalse (AsBool) -> () // Check that the value is within a range. Crashes if it is not in the range. // // Args: // - #x: Actual value. // - #x: Lower bound. // - #x: Upper bound. // // Notes: // - This could be done without Equals, except that some types have // "undefined" values (e.g., NaN, for Float) that prevent inferring equality // from less-than comparisons. @type checkBetween<#x> #x requires Formatted #x defines Equals<#x> #x defines LessThan<#x> (#x,#x,#x) -> () // Check that the value is above the limit. Crashes if it is not in the range. // // Args: // - #x: Actual value. // - #x: Lower bound. // // Notes: // - This could be done without Equals, except that some types have // "undefined" values (e.g., NaN, for Float) that prevent inferring equality // from less-than comparisons. // - This comparison doesn't allow the value to equal the bound. @type checkGreaterThan<#x> #x requires Formatted #x defines Equals<#x> #x defines LessThan<#x> (#x,#x) -> () // Check that the value is below the limit. Crashes if it is not in the range. // // Args: // - #x: Actual value. // - #x: Upper bound. // // Notes: // - This could be done without Equals, except that some types have // "undefined" values (e.g., NaN, for Float) that prevent inferring equality // from less-than comparisons. // - This comparison doesn't allow the value to equal the bound. @type checkLessThan<#x> #x requires Formatted #x defines Equals<#x> #x defines LessThan<#x> (#x,#x) -> () }