-
Notifications
You must be signed in to change notification settings - Fork 14
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 #119 from seasonedcc/take-5
Extracting primitives inspired by ATMP
- Loading branch information
Showing
31 changed files
with
1,150 additions
and
377 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
dist/ | ||
npm | ||
npm | ||
docs |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ import { | |
assertEquals, | ||
assertObjectMatch, | ||
} from './test-prelude.ts' | ||
import { z } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { z } from './test-prelude.ts' | ||
|
||
import { mdf } from './constructor.ts' | ||
import { all } from './domain-functions.ts' | ||
|
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,46 @@ | ||
import { assertEquals, describe, it } from './test-prelude.ts' | ||
import { z } from './test-prelude.ts' | ||
|
||
import { mdf } from './constructor.ts' | ||
import { applyEnvironment } from './domain-functions.ts' | ||
|
||
describe('applyEnvironment', () => { | ||
it('fails when environment fails parser', async () => { | ||
const getEnv = mdf(z.unknown(), z.number())((_, e) => e) | ||
|
||
const getEnvWithEnvironment = applyEnvironment( | ||
getEnv, | ||
'invalid environment', | ||
) | ||
|
||
assertEquals(await getEnvWithEnvironment('some input'), { | ||
success: false, | ||
errors: [], | ||
inputErrors: [], | ||
environmentErrors: [ | ||
{ | ||
message: 'Expected number, received string', | ||
path: [], | ||
}, | ||
], | ||
}) | ||
}) | ||
|
||
it('should apply environment', async () => { | ||
const getEnv = mdf(z.unknown(), z.string())((_, e) => e) | ||
|
||
const getEnvWithEnvironment = applyEnvironment( | ||
getEnv, | ||
'constant environment', | ||
) | ||
|
||
assertEquals(await getEnvWithEnvironment('some input'), { | ||
success: true, | ||
data: 'constant environment', | ||
errors: [], | ||
inputErrors: [], | ||
environmentErrors: [], | ||
}) | ||
}) | ||
}) | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ import { | |
assertEquals, | ||
assertObjectMatch, | ||
} from './test-prelude.ts' | ||
import { z } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { z } from './test-prelude.ts' | ||
|
||
import { mdf } from './constructor.ts' | ||
import { branch, pipe, all } from './domain-functions.ts' | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { describe, it, assertEquals } from './test-prelude.ts' | ||
import { z } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { z } from './test-prelude.ts' | ||
|
||
import { mdf } from './constructor.ts' | ||
import { collectSequence } from './domain-functions.ts' | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ import { | |
assertObjectMatch, | ||
assertEquals, | ||
} from './test-prelude.ts' | ||
import { z } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { z } from './test-prelude.ts' | ||
|
||
import { mdf } from './constructor.ts' | ||
import { collect } from './domain-functions.ts' | ||
|
Oops, something went wrong.