11import test from 'ava' ;
22import Core from '../../../lib/core' ;
33
4- test ( 'at' , ( t ) => {
4+ test ( 'at/1 ' , ( t ) => {
55 let result = Core . binary . at ( 'abc' , 0 ) ;
66 t . deepEqual ( result , 'a' ) ;
77} ) ;
88
9- test ( 'copy' , ( t ) => {
9+ test ( 'copy/1' , ( t ) => {
10+ let result = Core . binary . copy ( 'h' ) ;
11+ t . deepEqual ( result , 'h' ) ;
12+ } ) ;
13+
14+ test ( 'copy/2' , ( t ) => {
1015 let result = Core . binary . copy ( 'h' , 3 ) ;
1116 t . deepEqual ( result , 'hhh' ) ;
12-
13- result = Core . binary . copy ( 'h' ) ;
14- t . deepEqual ( result , 'h' ) ;
1517} ) ;
1618
17- test ( 'first' , ( t ) => {
19+ test ( 'first/1 ' , ( t ) => {
1820 let result = Core . binary . first ( 'abc' ) ;
1921 t . deepEqual ( result , 'a' ) ;
2022} ) ;
2123
22- test ( 'last' , ( t ) => {
24+ test ( 'last/1 ' , ( t ) => {
2325 let result = Core . binary . last ( 'abc' ) ;
2426 t . deepEqual ( result , 'c' ) ;
2527} ) ;
2628
27- test ( 'list_to_bin' , ( t ) => {
29+ test ( 'list_to_bin/1 ' , ( t ) => {
2830 const result = Core . binary . list_to_bin ( [ 104 , 101 , 108 , 108 , 111 ] ) ;
2931 t . deepEqual ( result , 'hello' ) ;
3032} ) ;
3133
32- test ( 'part' , ( t ) => {
34+ test ( 'part/2' , ( t ) => {
35+ let posLen = new Core . Tuple ( 1 , 1 )
36+ let result = Core . binary . part ( 'abcde' , posLen ) ;
37+ t . deepEqual ( result , 'b' ) ;
38+
39+ posLen = new Core . Tuple ( 1 , 3 )
40+ result = Core . binary . part ( 'abcde' , posLen ) ;
41+ t . deepEqual ( result , 'bcd' ) ;
42+ } ) ;
43+
44+ test ( 'part/3' , ( t ) => {
3345 let result = Core . binary . part ( 'abcde' , 1 , 1 ) ;
3446 t . deepEqual ( result , 'b' ) ;
3547
3648 result = Core . binary . part ( 'abcde' , 1 , 3 ) ;
3749 t . deepEqual ( result , 'bcd' ) ;
3850} ) ;
3951
40- test ( 'replace' , ( t ) => {
52+ test ( 'replace/3 ' , ( t ) => {
4153 let result = Core . binary . replace ( 'abcb' , 'b' , 'c' ) ;
4254 t . deepEqual ( result , 'accb' ) ;
55+ } ) ;
4356
44- //TODO: How to make a proplist here?
45- // result = Core.binary.replace('abcb', 'b', 'c', [global: true]);
46- // t.deepEqual(result, 'accc');
57+ test ( 'replace/4' , ( t ) => {
58+ let result = Core . binary . replace ( 'abcb' , 'b' , 'c' , [ new Core . Tuple ( Symbol . for ( ' global' ) , true ) ] ) ;
59+ t . deepEqual ( result , 'accc' ) ;
4760} ) ;
4861
49- test ( 'split' , ( t ) => {
62+ test ( 'split/2 ' , ( t ) => {
5063 let result = Core . binary . split ( 'abcd' , 'b' ) ;
5164 t . deepEqual ( result , [ 'a' , 'cd' ] ) ;
5265} ) ;
0 commit comments