forked from latitudegames/GPT-3-Encoder
-
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.
Merge pull request latitudegames#2 from schnerd/fix-exports
Fix exports & decoding
- Loading branch information
Showing
8 changed files
with
4,766 additions
and
8 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,30 @@ | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [12.x, 14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run build --if-present | ||
- run: npm test | ||
|
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
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 @@ | ||
const {encode, decode} = require('./Encoder.js'); | ||
|
||
test('empty string', () => { | ||
const str = ""; | ||
expect(encode(str)).toEqual([]) | ||
expect(decode(encode(str))).toEqual(str) | ||
}); | ||
|
||
test('space', () => { | ||
const str = " "; | ||
expect(encode(str)).toEqual([220]) | ||
expect(decode(encode(str))).toEqual(str) | ||
}); | ||
|
||
test('tab', () => { | ||
const str = "\t"; | ||
expect(encode(str)).toEqual([197]) | ||
expect(decode(encode(str))).toEqual(str) | ||
}); | ||
|
||
test('simple text', () => { | ||
const str = "This is some text"; | ||
expect(encode(str)).toEqual([1212, 318, 617, 2420]) | ||
expect(decode(encode(str))).toEqual(str) | ||
}); | ||
|
||
test('multi-token word', () => { | ||
const str = "indivisible"; | ||
expect(encode(str)).toEqual([521, 452, 12843]) | ||
expect(decode(encode(str))).toEqual(str) | ||
}); | ||
|
||
test('emojis', () => { | ||
const str = "hello 👋 world 🌍"; | ||
expect(encode(str)).toEqual([31373, 50169, 233, 995, 12520, 234, 235]) | ||
expect(decode(encode(str))).toEqual(str) | ||
}); |
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
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,11 @@ | ||
// For a detailed explanation regarding each configuration property, visit: | ||
// https://jestjs.io/docs/en/configuration.html | ||
|
||
module.exports = { | ||
// Automatically clear mock calls and instances between every test | ||
clearMocks: true, | ||
// Indicates which provider should be used to instrument code for coverage | ||
coverageProvider: "v8", | ||
// The test environment that will be used for testing | ||
testEnvironment: "node", | ||
}; |
Oops, something went wrong.