File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -99,4 +99,9 @@ export class IntegerRing {
99
99
return new Integer ( this . base , - 1 , [ 1 ] ) ;
100
100
}
101
101
102
+ has ( x ) {
103
+ if ( x instanceof Integer ) return true ;
104
+ return Number . isInteger ( x ) ;
105
+ }
106
+
102
107
}
Original file line number Diff line number Diff line change
1
+ import test from 'ava' ;
2
+
3
+ import { ZZ } from '../../../src' ;
4
+
5
+ const has = ( t , x ) => t . true ( ZZ . has ( x ) ) ;
6
+ has . title = ( providedTitle , x ) => `ZZ contains ${ x . toString ( ) } .`
7
+
8
+ const hasnot = ( t , x ) => t . false ( ZZ . has ( x ) ) ;
9
+ hasnot . title = ( providedTitle , x ) => `ZZ does not contain ${ JSON . stringify ( x ) } .`
10
+
11
+ test ( has , - 1 ) ;
12
+ test ( has , 0 ) ;
13
+ test ( has , 1 ) ;
14
+
15
+ test ( has , ZZ . from ( - 1234 ) ) ;
16
+
17
+ test ( has , ZZ . from ( '98213037479498473209740509327409327492744596398574' ) ) ;
18
+ test ( has , ZZ . from ( '-98213037479849847320974050937409327492744596398574' ) ) ;
19
+
20
+ test ( has , ZZ . from ( '3b' , 16 ) ) ;
21
+
22
+ test ( hasnot , '98213037479498473209740509327409327492744596398574' ) ;
23
+ test ( hasnot , '-98213037479849847320974050937409327492744596398574' ) ;
24
+
25
+ test ( hasnot , '0' ) ;
26
+ test ( hasnot , 'ff' ) ;
27
+ test ( hasnot , 'fdsalkjflsakjfd' ) ;
28
+
29
+ test ( hasnot , [ ] ) ;
30
+ test ( hasnot , { } ) ;
31
+ test ( hasnot , '' ) ;
32
+ test ( hasnot , false ) ;
33
+ test ( hasnot , true ) ;
34
+ test ( hasnot , 0.1 ) ;
35
+ test ( hasnot , - 0.5 ) ;
36
+ test ( hasnot , Math . PI ) ;
37
+ test ( hasnot , Math . E ) ;
You can’t perform that action at this time.
0 commit comments