|
| 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 wilcoxon = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns an object with ordered x-values and fitted values... |
| 25 | +{ |
| 26 | + const arr = [ 6, 8, 14, 16, 23, 24, 28, 29, 41, -48, 49, 56, 60, -67, 75 ]; |
| 27 | + wilcoxon( arr ); // $ExpectType Output |
| 28 | + wilcoxon( arr, { 'mu': 2 } ); // $ExpectType Output |
| 29 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 30 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 31 | + wilcoxon( x, y, { 'correction': false } ); // $ExpectType Output |
| 32 | +} |
| 33 | + |
| 34 | +// The function does not compile if provided a first argument that is not an array of numbers... |
| 35 | +{ |
| 36 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 37 | + wilcoxon( 'abc' ); // $ExpectError |
| 38 | + wilcoxon( true ); // $ExpectError |
| 39 | + wilcoxon( false ); // $ExpectError |
| 40 | + wilcoxon( null ); // $ExpectError |
| 41 | + wilcoxon( undefined ); // $ExpectError |
| 42 | + wilcoxon( 5 ); // $ExpectError |
| 43 | + wilcoxon( {} ); // $ExpectError |
| 44 | + wilcoxon( ( x: number ): number => x ); // $ExpectError |
| 45 | + |
| 46 | + wilcoxon( 'abc', y ); // $ExpectError |
| 47 | + wilcoxon( true, y ); // $ExpectError |
| 48 | + wilcoxon( false, y ); // $ExpectError |
| 49 | + wilcoxon( null, y ); // $ExpectError |
| 50 | + wilcoxon( undefined, y ); // $ExpectError |
| 51 | + wilcoxon( 5, y ); // $ExpectError |
| 52 | + wilcoxon( {}, y ); // $ExpectError |
| 53 | + wilcoxon( ( x: number ): number => x, y ); // $ExpectError |
| 54 | +} |
| 55 | + |
| 56 | +// The function does not compile if provided a second argument that is not an array of numbers or options object... |
| 57 | +{ |
| 58 | + const x = [ 6, 8, 14, 16, 23, 24, 28, 29, 41, -48, 49, 56, 60, -67, 75 ]; |
| 59 | + wilcoxon( x, 'abc' ); // $ExpectError |
| 60 | + wilcoxon( x, true ); // $ExpectError |
| 61 | + wilcoxon( x, false ); // $ExpectError |
| 62 | + wilcoxon( x, null ); // $ExpectError |
| 63 | + wilcoxon( x, 5 ); // $ExpectError |
| 64 | + wilcoxon( 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 = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 70 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 71 | + wilcoxon( x, y, true ); // $ExpectError |
| 72 | + wilcoxon( x, y, false ); // $ExpectError |
| 73 | + wilcoxon( x, y, null ); // $ExpectError |
| 74 | + wilcoxon( x, y, 5 ); // $ExpectError |
| 75 | + wilcoxon( x, y, 'abc' ); // $ExpectError |
| 76 | + wilcoxon( x, y, ( x: number ): number => x ); // $ExpectError |
| 77 | +} |
| 78 | + |
| 79 | +// The compiler throws an error if the function is provided an `alpha` option which is not a number... |
| 80 | +{ |
| 81 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 82 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 83 | + wilcoxon( x, y, { 'alpha': 'abc' } ); // $ExpectError |
| 84 | + wilcoxon( x, y, { 'alpha': true } ); // $ExpectError |
| 85 | + wilcoxon( x, y, { 'alpha': false } ); // $ExpectError |
| 86 | + wilcoxon( x, y, { 'alpha': null } ); // $ExpectError |
| 87 | + wilcoxon( x, y, { 'alpha': [] } ); // $ExpectError |
| 88 | + wilcoxon( x, y, { 'alpha': {} } ); // $ExpectError |
| 89 | + wilcoxon( x, y, { 'alpha': ( x: number ): number => x } ); // $ExpectError |
| 90 | +} |
| 91 | + |
| 92 | +// The compiler throws an error if the function is provided a `alternative` option which is not a recognized alternative... |
| 93 | +{ |
| 94 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 95 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 96 | + wilcoxon( x, y, { 'alternative': 'abc' } ); // $ExpectError |
| 97 | + wilcoxon( x, y, { 'alternative': 123 } ); // $ExpectError |
| 98 | + wilcoxon( x, y, { 'alternative': true } ); // $ExpectError |
| 99 | + wilcoxon( x, y, { 'alternative': false } ); // $ExpectError |
| 100 | + wilcoxon( x, y, { 'alternative': null } ); // $ExpectError |
| 101 | + wilcoxon( x, y, { 'alternative': [] } ); // $ExpectError |
| 102 | + wilcoxon( x, y, { 'alternative': {} } ); // $ExpectError |
| 103 | + wilcoxon( x, y, { 'alternative': ( x: number ): number => x } ); // $ExpectError |
| 104 | +} |
| 105 | + |
| 106 | +// The compiler throws an error if the function is provided a `zeroMethod` option which is not a recognized method... |
| 107 | +{ |
| 108 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 109 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 110 | + wilcoxon( x, y, { 'zeroMethod': 'abc' } ); // $ExpectError |
| 111 | + wilcoxon( x, y, { 'zeroMethod': 123 } ); // $ExpectError |
| 112 | + wilcoxon( x, y, { 'zeroMethod': true } ); // $ExpectError |
| 113 | + wilcoxon( x, y, { 'zeroMethod': false } ); // $ExpectError |
| 114 | + wilcoxon( x, y, { 'zeroMethod': null } ); // $ExpectError |
| 115 | + wilcoxon( x, y, { 'zeroMethod': [] } ); // $ExpectError |
| 116 | + wilcoxon( x, y, { 'zeroMethod': {} } ); // $ExpectError |
| 117 | + wilcoxon( x, y, { 'zeroMethod': ( x: number ): number => x } ); // $ExpectError |
| 118 | +} |
| 119 | + |
| 120 | +// The compiler throws an error if the function is provided a `correction` option which is not a boolean... |
| 121 | +{ |
| 122 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 123 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 124 | + wilcoxon( x, y, { 'correction': 'abc' } ); // $ExpectError |
| 125 | + wilcoxon( x, y, { 'correction': '123' } ); // $ExpectError |
| 126 | + wilcoxon( x, y, { 'correction': 123 } ); // $ExpectError |
| 127 | + wilcoxon( x, y, { 'correction': null } ); // $ExpectError |
| 128 | + wilcoxon( x, y, { 'correction': [] } ); // $ExpectError |
| 129 | + wilcoxon( x, y, { 'correction': {} } ); // $ExpectError |
| 130 | + wilcoxon( x, y, { 'correction': ( x: number ): number => x } ); // $ExpectError |
| 131 | +} |
| 132 | + |
| 133 | +// The compiler throws an error if the function is provided an `exact` option which is not a boolean... |
| 134 | +{ |
| 135 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 136 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 137 | + wilcoxon( x, y, { 'exact': 'abc' } ); // $ExpectError |
| 138 | + wilcoxon( x, y, { 'exact': '123' } ); // $ExpectError |
| 139 | + wilcoxon( x, y, { 'exact': 123 } ); // $ExpectError |
| 140 | + wilcoxon( x, y, { 'exact': null } ); // $ExpectError |
| 141 | + wilcoxon( x, y, { 'exact': [] } ); // $ExpectError |
| 142 | + wilcoxon( x, y, { 'exact': {} } ); // $ExpectError |
| 143 | + wilcoxon( x, y, { 'exact': ( x: number ): number => x } ); // $ExpectError |
| 144 | +} |
| 145 | + |
| 146 | +// The compiler throws an error if the function is provided a `mu` option which is not a number... |
| 147 | +{ |
| 148 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 149 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 150 | + wilcoxon( x, y, { 'mu': 'abc' } ); // $ExpectError |
| 151 | + wilcoxon( x, y, { 'mu': true } ); // $ExpectError |
| 152 | + wilcoxon( x, y, { 'mu': false } ); // $ExpectError |
| 153 | + wilcoxon( x, y, { 'mu': null } ); // $ExpectError |
| 154 | + wilcoxon( x, y, { 'mu': [] } ); // $ExpectError |
| 155 | + wilcoxon( x, y, { 'mu': {} } ); // $ExpectError |
| 156 | + wilcoxon( x, y, { 'mu': ( x: number ): number => x } ); // $ExpectError |
| 157 | +} |
| 158 | + |
| 159 | +// The function does not compile if provided an invalid number of arguments... |
| 160 | +{ |
| 161 | + const x = [ 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 ]; |
| 162 | + const y = [ 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29 ]; |
| 163 | + wilcoxon(); // $ExpectError |
| 164 | + wilcoxon( x, y, {}, {} ); // $ExpectError |
| 165 | +} |
0 commit comments