|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2021 The Stdlib Authors. |
| 5 | +* |
| 6 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +* you may not use this file except in compliance with the License. |
| 8 | +* You may obtain a copy of the License at |
| 9 | +* |
| 10 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +* |
| 12 | +* Unless required by applicable law or agreed to in writing, software |
| 13 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +* See the License for the specific language governing permissions and |
| 16 | +* limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +import ttest = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns a test result object... |
| 25 | +{ |
| 26 | + const x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; |
| 27 | + const y = [ 5.0, 5.0, 5.5, 7.0, 5.8 ]; |
| 28 | + ttest( x ); // $ExpectType Output |
| 29 | + ttest( x, { 'alpha': 0.1 } ); // $ExpectType Output |
| 30 | + ttest( x, y ); // $ExpectType Output |
| 31 | + ttest( x, y, { 'alpha': 0.1 } ); // $ExpectType Output |
| 32 | +} |
| 33 | + |
| 34 | +// The function does not compile if provided a first argument that is not a numeric array... |
| 35 | +{ |
| 36 | + const y = [ 5.0, 5.0, 5.5, 7.0, 5.8 ]; |
| 37 | + ttest( 'abc' ); // $ExpectError |
| 38 | + ttest( 123 ); // $ExpectError |
| 39 | + ttest( true ); // $ExpectError |
| 40 | + ttest( false ); // $ExpectError |
| 41 | + ttest( null ); // $ExpectError |
| 42 | + ttest( undefined ); // $ExpectError |
| 43 | + ttest( {} ); // $ExpectError |
| 44 | + ttest( ( x: number ): number => x ); // $ExpectError |
| 45 | + |
| 46 | + ttest( 'abc', y ); // $ExpectError |
| 47 | + ttest( 123, y ); // $ExpectError |
| 48 | + ttest( true, y ); // $ExpectError |
| 49 | + ttest( false, y ); // $ExpectError |
| 50 | + ttest( null, y ); // $ExpectError |
| 51 | + ttest( undefined, y ); // $ExpectError |
| 52 | + ttest( {}, y ); // $ExpectError |
| 53 | + ttest( ( x: number ): number => x, y ); // $ExpectError |
| 54 | +} |
| 55 | + |
| 56 | +// The function does not compile if provided a second argument that is neither a numeric array nor an options object... |
| 57 | +{ |
| 58 | + const x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; |
| 59 | + ttest( x, 'abc' ); // $ExpectError |
| 60 | + ttest( x, 123 ); // $ExpectError |
| 61 | + ttest( x, true ); // $ExpectError |
| 62 | + ttest( x, false ); // $ExpectError |
| 63 | + ttest( x, null ); // $ExpectError |
| 64 | + ttest( x, ( x: number ): number => x ); // $ExpectError |
| 65 | +} |
| 66 | + |
| 67 | +// The compiler throws an error if the function is provided a third argument which is not an options object... |
| 68 | +{ |
| 69 | + const x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; |
| 70 | + const y = [ 5.0, 5.0, 5.5, 7.0, 5.8 ]; |
| 71 | + ttest( x, y, true ); // $ExpectError |
| 72 | + ttest( x, y, false ); // $ExpectError |
| 73 | + ttest( x, y, null ); // $ExpectError |
| 74 | + ttest( x, y, 5 ); // $ExpectError |
| 75 | + ttest( x, y, 'abc' ); // $ExpectError |
| 76 | + ttest( x, y, [] ); // $ExpectError |
| 77 | + ttest( x, y, ( x: number ): number => x ); // $ExpectError |
| 78 | +} |
| 79 | + |
| 80 | +// The compiler throws an error if the function is provided an `alpha` option which is not a number... |
| 81 | +{ |
| 82 | + const x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; |
| 83 | + const y = [ 5.0, 5.0, 5.5, 7.0, 5.8 ]; |
| 84 | + ttest( x, { 'alpha': 'abc' } ); // $ExpectError |
| 85 | + ttest( x, { 'alpha': '123' } ); // $ExpectError |
| 86 | + ttest( x, { 'alpha': true } ); // $ExpectError |
| 87 | + ttest( x, { 'alpha': false } ); // $ExpectError |
| 88 | + ttest( x, { 'alpha': null } ); // $ExpectError |
| 89 | + ttest( x, { 'alpha': [] } ); // $ExpectError |
| 90 | + ttest( x, { 'alpha': {} } ); // $ExpectError |
| 91 | + ttest( x, { 'alpha': ( x: number ): number => x } ); // $ExpectError |
| 92 | + |
| 93 | + ttest( x, y, { 'alpha': 'abc' } ); // $ExpectError |
| 94 | + ttest( x, y, { 'alpha': '123' } ); // $ExpectError |
| 95 | + ttest( x, y, { 'alpha': true } ); // $ExpectError |
| 96 | + ttest( x, y, { 'alpha': false } ); // $ExpectError |
| 97 | + ttest( x, y, { 'alpha': null } ); // $ExpectError |
| 98 | + ttest( x, y, { 'alpha': [] } ); // $ExpectError |
| 99 | + ttest( x, y, { 'alpha': {} } ); // $ExpectError |
| 100 | + ttest( x, y, { 'alpha': ( x: number ): number => x } ); // $ExpectError |
| 101 | +} |
| 102 | + |
| 103 | +// The compiler throws an error if the function is provided an `alternative` option which is not a recognized alternative... |
| 104 | +{ |
| 105 | + const x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; |
| 106 | + const y = [ 5.0, 5.0, 5.5, 7.0, 5.8 ]; |
| 107 | + ttest( x, { 'alternative': 'abc' } ); // $ExpectError |
| 108 | + ttest( x, { 'alternative': 123 } ); // $ExpectError |
| 109 | + ttest( x, { 'alternative': true } ); // $ExpectError |
| 110 | + ttest( x, { 'alternative': false } ); // $ExpectError |
| 111 | + ttest( x, { 'alternative': null } ); // $ExpectError |
| 112 | + ttest( x, { 'alternative': [] } ); // $ExpectError |
| 113 | + ttest( x, { 'alternative': {} } ); // $ExpectError |
| 114 | + ttest( x, { 'alternative': ( x: number ): number => x } ); // $ExpectError |
| 115 | + |
| 116 | + ttest( x, y, { 'alternative': 'abc' } ); // $ExpectError |
| 117 | + ttest( x, y, { 'alternative': 123 } ); // $ExpectError |
| 118 | + ttest( x, y, { 'alternative': true } ); // $ExpectError |
| 119 | + ttest( x, y, { 'alternative': false } ); // $ExpectError |
| 120 | + ttest( x, y, { 'alternative': null } ); // $ExpectError |
| 121 | + ttest( x, y, { 'alternative': [] } ); // $ExpectError |
| 122 | + ttest( x, y, { 'alternative': {} } ); // $ExpectError |
| 123 | + ttest( x, y, { 'alternative': ( x: number ): number => x } ); // $ExpectError |
| 124 | +} |
| 125 | + |
| 126 | +// The compiler throws an error if the function is provided a `mu` option which is not a number... |
| 127 | +{ |
| 128 | + const x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; |
| 129 | + const y = [ 5.0, 5.0, 5.5, 7.0, 5.8 ]; |
| 130 | + ttest( x, { 'mu': 'abc' } ); // $ExpectError |
| 131 | + ttest( x, { 'mu': '123' } ); // $ExpectError |
| 132 | + ttest( x, { 'mu': true } ); // $ExpectError |
| 133 | + ttest( x, { 'mu': false } ); // $ExpectError |
| 134 | + ttest( x, { 'mu': null } ); // $ExpectError |
| 135 | + ttest( x, { 'mu': [] } ); // $ExpectError |
| 136 | + ttest( x, { 'mu': {} } ); // $ExpectError |
| 137 | + ttest( x, { 'mu': ( x: number ): number => x } ); // $ExpectError |
| 138 | + |
| 139 | + ttest( x, y, { 'mu': 'abc' } ); // $ExpectError |
| 140 | + ttest( x, y, { 'mu': '123' } ); // $ExpectError |
| 141 | + ttest( x, y, { 'mu': true } ); // $ExpectError |
| 142 | + ttest( x, y, { 'mu': false } ); // $ExpectError |
| 143 | + ttest( x, y, { 'mu': null } ); // $ExpectError |
| 144 | + ttest( x, y, { 'mu': [] } ); // $ExpectError |
| 145 | + ttest( x, y, { 'mu': {} } ); // $ExpectError |
| 146 | + ttest( x, y, { 'mu': ( x: number ): number => x } ); // $ExpectError |
| 147 | +} |
| 148 | + |
| 149 | +// The function does not compile if provided an invalid number of arguments... |
| 150 | +{ |
| 151 | + const x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; |
| 152 | + const y = [ 5.0, 5.0, 5.5, 7.0, 5.8 ]; |
| 153 | + ttest(); // $ExpectError |
| 154 | + ttest( x, y, {}, {} ); // $ExpectError |
| 155 | +} |
0 commit comments