-
-
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
d49b280
commit ea01ab1
Showing
8 changed files
with
139 additions
and
5 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,6 @@ | ||
/** | ||
* @file Entry Point - Test Types | ||
* @module tests/types | ||
*/ | ||
|
||
export type { default as NodeObject } from './node-object' |
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,15 @@ | ||
/** | ||
* @file Test Types - NodeObject | ||
* @module tests/types/NodeObject | ||
*/ | ||
|
||
import type { Node } from '@flex-development/esast' | ||
|
||
/** | ||
* Create an object mapping a node type to a node. | ||
* | ||
* @template {Node} T - Node to map | ||
*/ | ||
type NodeObject<T extends Node> = { [K in T['type']]: T } | ||
|
||
export type { NodeObject as default } |
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,47 @@ | ||
/** | ||
* @file Type Tests - BlockStatement | ||
* @module esast/nodes/tests/unit-d/BlockStatement | ||
*/ | ||
|
||
import type { Data, Parent, Statement } from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../statement-block' | ||
|
||
describe('unit-d:nodes/BlockStatement', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.BlockStatementData | ||
|
||
it('should extend Parent', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<Parent>() | ||
}) | ||
|
||
it('should match [children: Statement[]]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('children') | ||
.toEqualTypeOf<Statement[]>() | ||
}) | ||
|
||
it('should match [data?: Optional<BlockStatementData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [type: "blockStatement"]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('type') | ||
.toEqualTypeOf<'blockStatement'>() | ||
}) | ||
|
||
describe('BlockStatementData', () => { | ||
it('should extend Data', () => { | ||
expectTypeOf<SubjectData>().toMatchTypeOf<Data>() | ||
}) | ||
|
||
it('should match [static?: Nilable<boolean>]', () => { | ||
expectTypeOf<SubjectData>() | ||
.toHaveProperty('static') | ||
.toEqualTypeOf<Nilable<boolean>>() | ||
}) | ||
}) | ||
}) |
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,55 @@ | ||
/** | ||
* @file Nodes - BlockStatement | ||
* @module esast/nodes/BlockStatement | ||
*/ | ||
|
||
import type { Data, Parent, Statement } from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with block statements. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface BlockStatementData extends Data { | ||
/** | ||
* Static block statement? | ||
*/ | ||
static?: Nilable<boolean> | ||
} | ||
|
||
/** | ||
* A block statement. | ||
* | ||
* Block statements group zero (`0`) or more statements. The block is delimited | ||
* by a pair of braces ("curly braces") and contains a list of zero (`0`) or | ||
* more statements and declarations. | ||
* | ||
* @see {@linkcode Parent} | ||
* | ||
* @extends {Parent} | ||
*/ | ||
interface BlockStatement extends Parent { | ||
/** | ||
* List of children. | ||
* | ||
* @see {@linkcode Statement} | ||
*/ | ||
children: Statement[] | ||
|
||
/** | ||
* Info from the ecosystem. | ||
* | ||
* @see {@linkcode BlockStatementData} | ||
*/ | ||
data?: Optional<BlockStatementData> | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'blockStatement' | ||
} | ||
|
||
export type { BlockStatementData, BlockStatement as default } |
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