11
11
// See the License for the specific language governing permissions and
12
12
// limitations under the License.
13
13
14
- import JSBI from '../jsbi' ;
15
- import { assertEqual , assertTrue } from './assert' ;
14
+ /* eslint-disable max-len */
15
+ import JSBI from '../dist/jsbi.mjs' ;
16
+ import { assertEqual , assertTrue } from './assert.mjs' ;
16
17
17
18
{
18
19
// Test the example from the README.
@@ -51,7 +52,7 @@ import { assertEqual, assertTrue } from './assert';
51
52
// Emulate an environment that doesn't have Symbol (e.g. IE11)
52
53
// and make sure we can still coerce to primitive values.
53
54
// See #74.
54
- const globalSymbol = globalThis . Symbol ;
55
+ const globalSymbol = globalThis . Symbol ;
55
56
try {
56
57
globalThis . Symbol = undefined ;
57
58
assertTrue ( JSBI . EQ ( JSBI . BigInt ( 0x7FFFFFFF ) , {
@@ -104,7 +105,7 @@ const TESTS = [
104
105
b : '-0b1111111111111111111111111111111111111111111111111111111111111111' ,
105
106
expected : '-0b1111111111111111111111111111111111111111111111111111111111111111' ,
106
107
} ,
107
- { // https://github.com/GoogleChromeLabs/jsbi/issues/57
108
+ { // https://github.com/GoogleChromeLabs/jsbi/issues/57
108
109
operation : 'signedRightShift' ,
109
110
a : '-0xFFFFFFFFFFFFFFFF' ,
110
111
b : '32' ,
@@ -116,15 +117,15 @@ const TESTS = [
116
117
( function ( ) {
117
118
const VALID = [ '123' , ' 123 ' , ' 123 ' ] ;
118
119
const INVALID = [ 'x123' , 'x 123' , ' 123x' , '123 x' , '123 xx' , '123 ?a' ,
119
- '-0o0' , '-0x0' , '-0b0' , '-0x1' ] ;
120
+ '-0o0' , '-0x0' , '-0b0' , '-0x1' ] ;
120
121
for ( const v of VALID ) {
121
122
const result = JSBI . BigInt ( v ) ;
122
123
assertTrue ( JSBI . equal ( result , JSBI . BigInt ( 123 ) ) ) ;
123
124
}
124
125
for ( const i of INVALID ) {
125
126
try {
126
127
const result = JSBI . BigInt ( i ) ;
127
- throw " unreachable" ;
128
+ throw ' unreachable' ;
128
129
} catch ( exception ) {
129
130
assertTrue ( exception instanceof SyntaxError ) ;
130
131
}
@@ -135,7 +136,9 @@ const TESTS = [
135
136
( function ( ) {
136
137
const o = {
137
138
num : 123 ,
138
- [ Symbol . toPrimitive ] : function ( ) { return this . num ; }
139
+ [ Symbol . toPrimitive ] : function ( ) {
140
+ return this . num ;
141
+ } ,
139
142
} ;
140
143
const result = JSBI . BigInt ( o ) ;
141
144
assertTrue ( JSBI . equal ( result , JSBI . BigInt ( 123 ) ) ) ;
@@ -162,12 +165,12 @@ for (const test of TESTS) {
162
165
const expected = parse ( test . expected ) ;
163
166
const result = JSBI [ operation ] ( a , b ) ;
164
167
assertTrue (
165
- JSBI . equal ( result , expected ) ,
166
- `
168
+ JSBI . equal ( result , expected ) ,
169
+ `
167
170
Unexpected result.
168
171
${ hex ( a ) } ${ operation } ${ hex ( b ) }
169
172
Expected: ${ hex ( expected ) }
170
173
Actual: ${ hex ( result ) }
171
- ` . trim ( ) . replace ( / \t / g, '' )
174
+ ` . trim ( ) . replace ( / \t / g, '' ) ,
172
175
) ;
173
176
}
0 commit comments