|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2019 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 isAnagram = require( './index' ); |
| 20 | + |
| 21 | + |
| 22 | +// TESTS // |
| 23 | + |
| 24 | +// The function returns a boolean... |
| 25 | +{ |
| 26 | + isAnagram( 'I am a weakish speller', 'William Shakespeare' ); // $ExpectType boolean |
| 27 | + isAnagram( 'bat', 'tabba' ); // $ExpectType boolean |
| 28 | +} |
| 29 | + |
| 30 | +// The compiler throws an error if the returned accumulator function is provided invalid arguments... |
| 31 | +{ |
| 32 | + isAnagram( 5, 'a' ); // $ExpectError |
| 33 | + isAnagram( true, 'a' ); // $ExpectError |
| 34 | + isAnagram( false, 'a' ); // $ExpectError |
| 35 | + isAnagram( null, 'a' ); // $ExpectError |
| 36 | + isAnagram( {}, 'a' ); // $ExpectError |
| 37 | + isAnagram( [], 'a' ); // $ExpectError |
| 38 | + isAnagram( ( x: number ): number => x, 'a' ); // $ExpectError |
| 39 | +} |
| 40 | + |
| 41 | +// The compiler throws an error if the function is provided an unsupported number of arguments... |
| 42 | +{ |
| 43 | + isAnagram(); // $ExpectError |
| 44 | + isAnagram( 'bat' ); // $ExpectError |
| 45 | +} |
0 commit comments