-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3dc85c8
Showing
11 changed files
with
5,150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], | ||
overrides: [ | ||
{ | ||
env: { | ||
node: true, | ||
}, | ||
files: ['.eslintrc.{js,cjs}'], | ||
parserOptions: { | ||
sourceType: 'script', | ||
}, | ||
}, | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 100, | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { FULL_MASK, Instruction } from '../src/common'; | ||
import { InstructionCodec } from '../src/instruction'; | ||
|
||
describe('InstructionCodec works', () => { | ||
describe("Parsing works", () => { | ||
test('parses a Partition instruction correctly', () => { | ||
const codec = new InstructionCodec(); | ||
const result = codec.deserialize('PARTITION(5,1)'); | ||
expect(result).toEqual({ kind: 'Partition', pivot: 5, ownPart: 1 }); | ||
}); | ||
|
||
test('parses an Interlace instruction correctly', () => { | ||
const codec = new InstructionCodec(); | ||
const result = codec.deserialize(`INTERLACE(${FULL_MASK})`); | ||
expect(result).toEqual({ kind: 'Interlace', ownMask: FULL_MASK }); | ||
}); | ||
|
||
test('throws an error for unknown instruction kind', () => { | ||
const codec = new InstructionCodec(); | ||
expect(() => codec.deserialize('UNKNOWN(1,2)')).toThrow('Unknown instruction'); | ||
}); | ||
}); | ||
|
||
describe("Serialization works", () => { | ||
test('serializes a Partition instruction correctly', () => { | ||
const codec = new InstructionCodec(); | ||
const instruction: Instruction = { kind: 'Partition', pivot: 5, ownPart: 1 }; | ||
expect(codec.serialize(instruction)).toEqual('PARTITION(5,1)'); | ||
}); | ||
|
||
test('serializes an Interlace instruction correctly', () => { | ||
const codec = new InstructionCodec(); | ||
const instruction: Instruction = { kind: 'Interlace', ownMask: FULL_MASK }; | ||
expect(codec.serialize(instruction)).toEqual(`INTERLACE(${FULL_MASK})`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; | ||
|
Oops, something went wrong.