Skip to content

Commit 18bd176

Browse files
test: update typescript test
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 05758a3 commit 18bd176

1 file changed

Lines changed: 42 additions & 12 deletions

File tree

  • lib/node_modules/@stdlib/number/uint64/ctor/docs/types

lib/node_modules/@stdlib/number/uint64/ctor/docs/types/test.ts

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,36 @@
1818

1919
/* eslint-disable @typescript-eslint/no-unused-expressions */
2020

21+
import Uint32Array = require( '@stdlib/array/uint32' );
2122
import Uint64 = require( './index' );
2223

2324

2425
// TESTS //
2526

26-
// The function returns a Unsigned 64-bit integer with the expected properties...
27+
// The function returns an unsigned 64-bit integer with the expected properties...
2728
{
2829
const x = new Uint64( 5 ); // $ExpectType Uint64
29-
30-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
3130
x.hi; // $ExpectType number
32-
33-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
3431
x.lo; // $ExpectType number
35-
36-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
3732
x.BYTES_PER_ELEMENT; // $ExpectType 8
38-
39-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
4033
x.byteLength; // $ExpectType 8
4134
}
4235

4336
// Unsigned 64-bit integer comes with a `toString` method to serialize an instance as a string...
4437
{
4538
const x = new Uint64( 5 ); // $ExpectType Uint64
46-
4739
x.toString(); // $ExpectType string
4840
}
4941

5042
// Unsigned 64-bit integer comes with a `toJSON` method to serialize an instance as a JSON object....
5143
{
5244
const x = new Uint64( 5 ); // $ExpectType Uint64
53-
5445
x.toJSON(); // $ExpectType SerializedUint64
5546
}
5647

5748
// Unsigned 64-bit integer comes with a `valueOf` method to serialize an instance to a primitive value...
5849
{
5950
const x = new Uint64( 5 ); // $ExpectType Uint64
60-
6151
x.valueOf(); // $ExpectType number | bigint
6252
}
6353

@@ -66,8 +56,48 @@ import Uint64 = require( './index' );
6656
Uint64( 5 ); // $ExpectError
6757
}
6858

59+
// The compiler throws an error if the constructor is provided a first argument that is not a number or big int...
60+
{
61+
new Uint64( true ); // $ExpectError
62+
new Uint64( false ); // $ExpectError
63+
new Uint64( null ); // $ExpectError
64+
new Uint64( 'abc' ); // $ExpectError
65+
new Uint64( {} ); // $ExpectError
66+
new Uint64( ( x: number ): number => x ); // $ExpectError
67+
}
68+
6969
// The compiler throws an error if the constructor is provided an unsupported number of arguments...
7070
{
7171
new Uint64(); // $ExpectError
7272
new Uint64( 5, 3 ); // $ExpectError
7373
}
74+
75+
// The `from` method returns an unsigned 64-bit integer...
76+
{
77+
Uint64.from( [ 0, 1 ] ); // $ExpectType Uint64
78+
Uint64.from( new Uint32Array( [ 0, 1 ] ) ); // $ExpectType Uint64
79+
Uint64.from( { '0': 10, '1': 20, 'length': 2 } ); // $ExpectType Uint64
80+
}
81+
82+
// The compiler throws an error if the `from` method is provided an argument which is not array-like...
83+
{
84+
Uint64.from( true ); // $ExpectError
85+
Uint64.from( false ); // $ExpectError
86+
Uint64.from( 123 ); // $ExpectError
87+
Uint64.from( null ); // $ExpectError
88+
Uint64.from( {} ); // $ExpectError
89+
}
90+
91+
// The `of` method returns an unsigned 64-bit integer...
92+
{
93+
Uint64.of( 0, 1 ); // $ExpectType Uint64
94+
}
95+
96+
// The compiler throws an error if the `of` method is provided arguments that are not numbers...
97+
{
98+
Uint64.of( 'abc', 'def' ); // $ExpectError
99+
Uint64.of( true, false ); // $ExpectError
100+
Uint64.of( {}, [] ); // $ExpectError
101+
Uint64.of( null, null ); // $ExpectError
102+
}
103+

0 commit comments

Comments
 (0)