-
-
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.
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
d2fac9c
commit 3b542c6
Showing
27 changed files
with
1,630 additions
and
13 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
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
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,42 @@ | ||
/** | ||
* @file Test Setup - expect | ||
* @module tests/setup/expect | ||
*/ | ||
|
||
import type Token from '#src/token' | ||
import { | ||
ParseError, | ||
result, | ||
type ParserOutput, | ||
type TokenType as TT | ||
} from '@flex-development/unist-util-parsec' | ||
|
||
/** | ||
* Expect a failed parser output object. | ||
* | ||
* @param {ParserOutput<TT, unknown>} output - Parser output | ||
* @return {undefined} Nothing | ||
*/ | ||
function failed(output: ParserOutput<TT, unknown>): undefined { | ||
void expect(output.successful).to.be.false | ||
expect(output.error).to.be.instanceof(ParseError) | ||
return void output | ||
} | ||
|
||
/** | ||
* Expect a succeeded parser output object. | ||
* | ||
* @param {ParserOutput<TT, unknown>} output - Parser output | ||
* @param {Token} token - Head token | ||
* @return {undefined} Nothing | ||
*/ | ||
function succeeded(output: ParserOutput<TT, unknown>, token: Token): undefined { | ||
void expect(() => result(output)).not.to.throw | ||
expect(output.candidate).to.have.property('head', token) | ||
expect(output.candidate).to.have.property('next', undefined) | ||
expect(output.candidate).to.have.property('result') | ||
return void output | ||
} | ||
|
||
global.expect.failed = failed | ||
global.expect.succeeded = succeeded |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
* @module tests/setup | ||
*/ | ||
|
||
import './expect' | ||
import './faker' |
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 @@ | ||
/** | ||
* @file Test Utilities - test | ||
* @module tests/utils/test | ||
*/ | ||
|
||
import { tt } from '#src/enums' | ||
import type Token from '#src/token' | ||
import { | ||
kmid, | ||
tok, | ||
type ParserOutput, | ||
type Runner, | ||
type TokenType | ||
} from '@flex-development/unist-util-parsec' | ||
|
||
/** | ||
* Parse an occurrence of `x`, bounded by start and end of file tokens. | ||
* | ||
* @see {@linkcode ParserOutput} | ||
* @see {@linkcode Runner} | ||
* @see {@linkcode TokenType} | ||
* @see {@linkcode Token} | ||
* | ||
* @template {any} R - Parse candidate result | ||
* | ||
* @param {Runner<TokenType, R>} x - Parser to apply | ||
* @param {Token | undefined} token - Current token | ||
* @return {ParserOutput<TokenType, R>} Parser output | ||
*/ | ||
function test<R>( | ||
x: Runner<TokenType, R>, | ||
token: Token | undefined | ||
): ParserOutput<TokenType, R> { | ||
return kmid(tok(tt.sof), x, tok(tt.eof)).parse(token) | ||
} | ||
|
||
export default 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
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
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,165 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`unit:parsers/PunctuatorParser > #arrow > should parse "=>" 1`] = ` | ||
tokens[2] | ||
├─0 punctuator "=" (1:1-1:2, 0-1) | ||
│ whitespace: "" | ||
└─1 punctuator ">" (1:2-1:3, 1-2) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > #ellipsis > should parse "..." 1`] = ` | ||
tokens[3] | ||
├─0 punctuator "." (1:1-1:2, 0-1) | ||
│ whitespace: "" | ||
├─1 punctuator "." (1:2-1:3, 1-2) | ||
│ whitespace: "" | ||
└─2 punctuator "." (1:3-1:4, 2-3) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.ampersand 1`] = ` | ||
punctuator "&" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.asterisk 1`] = ` | ||
punctuator "*" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.at 1`] = ` | ||
punctuator "@" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.backslash 1`] = ` | ||
punctuator "\\\\" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.backtick 1`] = ` | ||
punctuator "\`" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.bar 1`] = ` | ||
punctuator "|" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.caret 1`] = ` | ||
punctuator "^" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.colon 1`] = ` | ||
punctuator ":" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.comma 1`] = ` | ||
punctuator "," (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.dollar 1`] = ` | ||
keyid "$" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
private: false | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.dot 1`] = ` | ||
punctuator "." (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.equal 1`] = ` | ||
punctuator "=" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.exclamation 1`] = ` | ||
punctuator "!" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.gt 1`] = ` | ||
punctuator ">" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.hash 1`] = ` | ||
punctuator "#" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
|
||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.leftBrace 1`] = ` | ||
punctuator "{" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.leftBracket 1`] = ` | ||
punctuator "[" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.leftParen 1`] = ` | ||
punctuator "(" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.lt 1`] = ` | ||
punctuator "<" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.minus 1`] = ` | ||
punctuator "-" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.percent 1`] = ` | ||
punctuator "%" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.plus 1`] = ` | ||
punctuator "+" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.question 1`] = ` | ||
punctuator "?" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.rightBrace 1`] = ` | ||
punctuator "}" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.rightBracket 1`] = ` | ||
punctuator "]" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.rightParen 1`] = ` | ||
punctuator ")" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.semicolon 1`] = ` | ||
punctuator ";" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.slash 1`] = ` | ||
punctuator "/" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; | ||
exports[`unit:parsers/PunctuatorParser > chars > should parse chars.tilde 1`] = ` | ||
punctuator "~" (1:1-1:2, 0-1) | ||
whitespace: "" | ||
`; |
Oops, something went wrong.