/* ----------------------------------------------------------------------------- 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 value for empty. Crashes if present. // // Args: // - optional Formatted: Actual value. @type checkEmpty (optional Formatted) -> () // 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 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) -> () }