1
1
import * as fs from 'fs' ;
2
2
3
- import * as fb from '../fat-binary ' ;
3
+ import * as uh from '../universal-hex ' ;
4
4
5
5
const hex1 = fs . readFileSync (
6
6
'./src/__tests__/hex-files/1-duck-umbrella.hex' ,
@@ -40,7 +40,7 @@ describe('Test iHexToCustomFormat()', () => {
40
40
':1000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
41
41
':0400000BFFFFFFFFF5\n' ;
42
42
43
- const result = fb . iHexToCustomFormat ( hexStr , 0x9903 ) ;
43
+ const result = uh . iHexToCustomFormat ( hexStr , 0x9903 ) ;
44
44
45
45
expect ( result ) . toEqual ( expected ) ;
46
46
expect ( result . length ) . toEqual ( 512 ) ;
@@ -78,7 +78,7 @@ describe('Test iHexToCustomFormat()', () => {
78
78
':0C10D000FFFFFFFF2D6D0300000000007B\n' +
79
79
':0000000BF5\n' ;
80
80
81
- const result = fb . iHexToCustomFormat ( hexStr , 0x9901 ) ;
81
+ const result = uh . iHexToCustomFormat ( hexStr , 0x9901 ) ;
82
82
83
83
expect ( result ) . toEqual ( expected ) ;
84
84
expect ( result . length ) . toEqual ( 512 ) ;
@@ -131,7 +131,7 @@ describe('Test iHexToCustomFormat()', () => {
131
131
':1000000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4\n' +
132
132
':1000000BFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5\n' ;
133
133
134
- const result = fb . iHexToCustomFormat ( hexStr , 0x9901 ) ;
134
+ const result = uh . iHexToCustomFormat ( hexStr , 0x9901 ) ;
135
135
136
136
expect ( result ) . toEqual ( expected ) ;
137
137
expect ( result . length ) . toEqual ( 1024 ) ;
@@ -163,8 +163,8 @@ describe('Test iHexToCustomFormat()', () => {
163
163
const expected9901 = [ ...expected9900 ] ;
164
164
expected9901 [ 1 ] = ':0400000A9901C0DEBA\n' ;
165
165
166
- const result9900 = fb . iHexToCustomFormat ( hexStr , 0x9900 ) ;
167
- const result9901 = fb . iHexToCustomFormat ( hexStr , 0x9901 ) ;
166
+ const result9900 = uh . iHexToCustomFormat ( hexStr , 0x9900 ) ;
167
+ const result9901 = uh . iHexToCustomFormat ( hexStr , 0x9901 ) ;
168
168
169
169
expect ( result9900 ) . toEqual ( expected9900 . join ( '' ) ) ;
170
170
expect ( result9900 . length ) . toEqual ( 512 ) ;
@@ -199,11 +199,11 @@ describe('Test iHexToCustomFormat()', () => {
199
199
const expectedFFFF = [ ...expected9903 ] ;
200
200
expectedFFFF [ 1 ] = ':0400000AFFFFC0DE56\n' ;
201
201
202
- const result9903 = fb . iHexToCustomFormat ( hexStr , 0x9903 ) ;
203
- const result9904 = fb . iHexToCustomFormat ( hexStr , 0x9904 ) ;
204
- const result9910 = fb . iHexToCustomFormat ( hexStr , 0x9910 ) ;
205
- const result0000 = fb . iHexToCustomFormat ( hexStr , 0 ) ;
206
- const resultFFFF = fb . iHexToCustomFormat ( hexStr , 0xffff ) ;
202
+ const result9903 = uh . iHexToCustomFormat ( hexStr , 0x9903 ) ;
203
+ const result9904 = uh . iHexToCustomFormat ( hexStr , 0x9904 ) ;
204
+ const result9910 = uh . iHexToCustomFormat ( hexStr , 0x9910 ) ;
205
+ const result0000 = uh . iHexToCustomFormat ( hexStr , 0 ) ;
206
+ const resultFFFF = uh . iHexToCustomFormat ( hexStr , 0xffff ) ;
207
207
208
208
expect ( result9903 ) . toEqual ( expected9903 . join ( '' ) ) ;
209
209
expect ( result9904 ) . toEqual ( expected9904 . join ( '' ) ) ;
@@ -230,7 +230,7 @@ describe('Test iHexToCustomFormat()', () => {
230
230
':0000000BF5\n' +
231
231
':00000001FF\n' ;
232
232
233
- const result = fb . iHexToCustomFormat ( hexStr , 0x9903 ) ;
233
+ const result = uh . iHexToCustomFormat ( hexStr , 0x9903 ) ;
234
234
235
235
expect ( result ) . toEqual ( expected ) ;
236
236
} ) ;
@@ -274,7 +274,7 @@ describe('Test iHexToCustomFormat()', () => {
274
274
':0000000BF5\n' +
275
275
':00000001FF\n' ;
276
276
277
- const result = fb . iHexToCustomFormat ( hexStr , 0x9901 ) ;
277
+ const result = uh . iHexToCustomFormat ( hexStr , 0x9901 ) ;
278
278
279
279
expect ( result ) . toEqual ( expected ) ;
280
280
} ) ;
@@ -354,21 +354,21 @@ describe('Test iHexToCustomFormat()', () => {
354
354
':0000000BF5\n' +
355
355
':00000001FF\n' ;
356
356
357
- const result = fb . iHexToCustomFormat ( hexStr , 0x9901 ) ;
357
+ const result = uh . iHexToCustomFormat ( hexStr , 0x9901 ) ;
358
358
359
359
expect ( result ) . toEqual ( expected ) ;
360
360
} ) ;
361
361
362
362
it ( 'Empty Hex string produces an empty-ish output' , ( ) => {
363
- const result = fb . iHexToCustomFormat ( '' , 0x9903 ) ;
363
+ const result = uh . iHexToCustomFormat ( '' , 0x9903 ) ;
364
364
365
365
expect ( result ) . toEqual ( '' ) ;
366
366
} ) ;
367
367
} ) ;
368
368
369
- describe ( 'Test createFatBinary ()' , ( ) => {
369
+ describe ( 'Test createUniversalHex ()' , ( ) => {
370
370
it ( 'Empty input equals empty output' , ( ) => {
371
- const result = fb . createFatBinary ( [ ] ) ;
371
+ const result = uh . createUniversalHex ( [ ] ) ;
372
372
373
373
expect ( result ) . toEqual ( '' ) ;
374
374
} ) ;
@@ -385,30 +385,30 @@ describe('Test createFatBinary()', () => {
385
385
);
386
386
387
387
it('.', () => {
388
- const result1 = fb .iHexToCustomFormat(hex1, 0x9901);
388
+ const result1 = uh .iHexToCustomFormat(hex1, 0x9901);
389
389
fs.writeFileSync('./src/__tests__/hex-files/test-output-1.hex', result1);
390
- const result2 = fb .iHexToCustomFormat(hex2, 0x9903);
390
+ const result2 = uh .iHexToCustomFormat(hex2, 0x9903);
391
391
fs.writeFileSync('./src/__tests__/hex-files/test-output-2.hex', result2);
392
392
393
393
expect('').toEqual('');
394
394
});
395
395
396
396
it('..', () => {
397
- const result = fb.createFatBinary ([
397
+ const result = uh.createUniversalHex ([
398
398
{ hex: hex1, boardID: 0x9901 },
399
399
{ hex: hex2, boardID: 0x9903 },
400
400
]);
401
- fs.writeFileSync('./src/__tests__/hex-files/test-output-fat .hex', result);
401
+ fs.writeFileSync('./src/__tests__/hex-files/test-output-universal .hex', result);
402
402
403
403
expect('').toEqual('');
404
404
});
405
405
*/
406
406
} ) ;
407
407
408
- describe ( 'Separate fat binaries ' , ( ) => {
408
+ describe ( 'Separate a Universal Hex ' , ( ) => {
409
409
it ( 'Throws an error on empty input' , ( ) => {
410
410
expect ( ( ) => {
411
- const result = fb . separateFatBinary ( '' ) ;
411
+ const result = uh . separateUniversalHex ( '' ) ;
412
412
} ) . toThrow ( 'Empty' ) ;
413
413
} ) ;
414
414
@@ -420,7 +420,7 @@ describe('Separate fat binaries', () => {
420
420
':00000001FF\n' ;
421
421
422
422
expect ( ( ) => {
423
- fb . separateFatBinary ( normalHex ) ;
423
+ uh . separateUniversalHex ( normalHex ) ;
424
424
} ) . toThrow ( 'format invalid' ) ;
425
425
} ) ;
426
426
@@ -436,7 +436,7 @@ describe('Separate fat binaries', () => {
436
436
':00000001FF\n' ;
437
437
438
438
expect ( ( ) => {
439
- fb . separateFatBinary ( simpleBlock ) ;
439
+ uh . separateUniversalHex ( simpleBlock ) ;
440
440
} ) . toThrow ( 'Block Start record invalid: :0400000A9901BA' ) ;
441
441
} ) ;
442
442
@@ -487,15 +487,15 @@ describe('Separate fat binaries', () => {
487
487
':1056F0005746591C62408C4607430F2F5CD86F49B0\n' +
488
488
':00000001FF\n' ;
489
489
490
- const result = fb . separateFatBinary ( firstBlock + secondBlock ) ;
490
+ const result = uh . separateUniversalHex ( firstBlock + secondBlock ) ;
491
491
expect ( result [ 0 ] . boardId ) . toEqual ( 0x9901 ) ;
492
492
expect ( result [ 0 ] . hex ) . toEqual ( firstHex ) ;
493
493
expect ( result [ 1 ] . boardId ) . toEqual ( 0x9903 ) ;
494
494
expect ( result [ 1 ] . hex ) . toEqual ( secondHex ) ;
495
495
} ) ;
496
496
497
497
it ( 'Separate a full hex file' , ( ) => {
498
- const result = fb . separateFatBinary ( hexCombined ) ;
498
+ const result = uh . separateUniversalHex ( hexCombined ) ;
499
499
// fs.writeFileSync(
500
500
// './src/__tests__/hex-files/test-separate-0.hex',
501
501
// result[0].hex
@@ -513,7 +513,7 @@ describe('Separate fat binaries', () => {
513
513
} ) ;
514
514
} ) ;
515
515
516
- describe ( 'Loopback hex to fat binaries ' , ( ) => {
516
+ describe ( 'Loopback Intel Hex to Universal Hex ' , ( ) => {
517
517
it ( 'From a small sample' , ( ) => {
518
518
const hexStr =
519
519
':020000040000FA\n' +
@@ -547,15 +547,15 @@ describe('Loopback hex to fat binaries', () => {
547
547
':1056E00080220020ED00D20415437F3BFB18424688\n' +
548
548
':1056F0005746591C62408C4607430F2F5CD86F49B0\n' +
549
549
':00000001FF\n' ;
550
- const fatBinary = fb . iHexToCustomFormat ( hexStr , 0x9901 ) ;
550
+ const universalHex = uh . iHexToCustomFormat ( hexStr , 0x9901 ) ;
551
551
552
- const result = fb . separateFatBinary ( fatBinary ) ;
552
+ const result = uh . separateUniversalHex ( universalHex ) ;
553
553
554
554
expect ( result [ 0 ] . hex ) . toEqual ( hexStr ) ;
555
555
} ) ;
556
556
557
557
it ( 'From full MakeCode files' , ( ) => {
558
- const fatBinary = fb . createFatBinary ( [
558
+ const universalHex = uh . createUniversalHex ( [
559
559
{
560
560
hex : hex1 ,
561
561
boardId : 0x1 ,
@@ -566,7 +566,7 @@ describe('Loopback hex to fat binaries', () => {
566
566
} ,
567
567
] ) ;
568
568
569
- const result = fb . separateFatBinary ( fatBinary ) ;
569
+ const result = uh . separateUniversalHex ( universalHex ) ;
570
570
571
571
expect ( result [ 0 ] . boardId ) . toEqual ( 1 ) ;
572
572
expect ( result [ 0 ] . hex ) . toEqual ( hex1 ) ;
0 commit comments