Skip to content

Commit 7273be7

Browse files
committed
add docstring tests to Stdlib.BigInt
1 parent c67ab51 commit 7273be7

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

runtime/Stdlib_BigInt.res

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,20 @@ number as a `bigint` if successfully parsed. Uncaught syntax exception otherwise
1616
## Examples
1717
1818
```rescript
19-
/* returns 123n */
20-
BigInt.fromStringExn("123")
19+
BigInt.fromStringExn("123")->assertEqual(123n)
2120
22-
/* returns 0n */
23-
BigInt.fromStringExn("")
21+
BigInt.fromStringExn("")->assertEqual(0n)
2422
25-
/* returns 17n */
26-
BigInt.fromStringExn("0x11")
23+
BigInt.fromStringExn("0x11")->assertEqual(17n)
2724
28-
/* returns 3n */
29-
BigInt.fromStringExn("0b11")
25+
BigInt.fromStringExn("0b11")->assertEqual(3n)
3026
31-
/* returns 9n */
32-
BigInt.fromStringExn("0o11")
27+
BigInt.fromStringExn("0o11")->assertEqual(9n)
3328
3429
/* catch exception */
35-
try {
36-
BigInt.fromStringExn("a")
37-
} catch {
38-
| Exn.Error(_error) => 0n
30+
switch BigInt.fromStringExn("a") {
31+
| exception Exn.Error(_error) => assert(true)
32+
| _bigInt => assert(false)
3933
}
4034
```
4135
*/
@@ -51,8 +45,7 @@ See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen
5145
## Examples
5246
5347
```rescript
54-
/* prints "123" */
55-
BigInt.toString(123n)->Console.log
48+
BigInt.toString(123n)->assertEqual("123")
5649
```
5750
*/
5851
external toString: (bigint, ~radix: int=?) => string = "toString"
@@ -67,8 +60,7 @@ Returns a string with a language-sensitive representation of this BigInt value.
6760
## Examples
6861
6962
```rescript
70-
/* prints "123" */
71-
BigInt.toString(123n)->Console.log
63+
BigInt.toString(123n)->assertEqual("123")
7264
```
7365
*/
7466
external toLocaleString: bigint => string = "toLocaleString"

0 commit comments

Comments
 (0)