-
-
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.
feat(nodes):
ForInStatement
, ForOfStatement
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
cd30760
commit 6025de8
Showing
9 changed files
with
261 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
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,35 @@ | ||
/** | ||
* @file Type Tests - ForInStatement | ||
* @module esast/nodes/tests/unit-d/ForInStatement | ||
*/ | ||
|
||
import type { Data, ForXStatement } from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../statement-for-in' | ||
|
||
describe('unit-d:nodes/ForInStatement', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.ForInStatementData | ||
|
||
it('should extend ForXStatement', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<ForXStatement>() | ||
}) | ||
|
||
it('should match [data?: Optional<ForInStatementData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [type: "forInStatement"]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('type') | ||
.toEqualTypeOf<'forInStatement'>() | ||
}) | ||
|
||
describe('ForInStatementData', () => { | ||
it('should extend Data', () => { | ||
expectTypeOf<SubjectData>().toMatchTypeOf<Data>() | ||
}) | ||
}) | ||
}) |
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,41 @@ | ||
/** | ||
* @file Type Tests - ForOfStatement | ||
* @module esast/nodes/tests/unit-d/ForOfStatement | ||
*/ | ||
|
||
import type { Data, ForXStatement } from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../statement-for-of' | ||
|
||
describe('unit-d:nodes/ForOfStatement', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.ForOfStatementData | ||
|
||
it('should extend ForXStatement', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<ForXStatement>() | ||
}) | ||
|
||
it('should match [data?: Optional<ForOfStatementData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [type: "forOfStatement"]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('type') | ||
.toEqualTypeOf<'forOfStatement'>() | ||
}) | ||
|
||
describe('ForOfStatementData', () => { | ||
it('should extend Data', () => { | ||
expectTypeOf<SubjectData>().toMatchTypeOf<Data>() | ||
}) | ||
|
||
it('should match [await?: Nilable<boolean>]', () => { | ||
expectTypeOf<SubjectData>() | ||
.toHaveProperty('await') | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @file Type Tests - ForXStatement | ||
* @module esast/nodes/tests/unit-d/ForXStatement | ||
*/ | ||
|
||
import type { | ||
Expression, | ||
Parent, | ||
Pattern, | ||
Statement, | ||
VariableDeclaration | ||
} from '@flex-development/esast' | ||
import type TestSubject from '../statement-for-x' | ||
|
||
describe('unit-d:nodes/ForXStatement', () => { | ||
it('should extend Parent', () => { | ||
expectTypeOf<TestSubject>().toMatchTypeOf<Parent>() | ||
}) | ||
|
||
it('should match [children: [Pattern | VariableDeclaration, Expression, Statement]]', () => { | ||
// Arrange | ||
type Expect = [Pattern | VariableDeclaration, Expression, Statement] | ||
|
||
// Expect | ||
expectTypeOf<TestSubject>() | ||
.toHaveProperty('children') | ||
.toEqualTypeOf<Expect>() | ||
}) | ||
|
||
it('should match [type: `for${Uppercase<string>}${string}`]', () => { | ||
expectTypeOf<TestSubject>() | ||
.toHaveProperty('type') | ||
.toEqualTypeOf<`for${Uppercase<string>}${string}`>() | ||
}) | ||
}) |
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,39 @@ | ||
/** | ||
* @file Nodes - ForInStatement | ||
* @module esast/nodes/ForInStatement | ||
*/ | ||
|
||
import type { Data, ForXStatement } from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with `for...in` statements. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface ForInStatementData extends Data {} | ||
|
||
/** | ||
* A `for...in` statement. | ||
* | ||
* @see {@linkcode ForXStatement} | ||
* | ||
* @extends {ForXStatement} | ||
*/ | ||
interface ForInStatement extends ForXStatement { | ||
/** | ||
* Info from the ecosystem. | ||
* | ||
* @see {@linkcode ForInStatementData} | ||
*/ | ||
data?: Optional<ForInStatementData> | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'forInStatement' | ||
} | ||
|
||
export type { ForInStatementData, ForInStatement 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @file Nodes - ForOfStatement | ||
* @module esast/nodes/ForOfStatement | ||
*/ | ||
|
||
import type { Data, ForXStatement } from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with `for...of` statements. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface ForOfStatementData extends Data { | ||
/** | ||
* Asynchronous statement? | ||
*/ | ||
await?: Nilable<boolean> | ||
} | ||
|
||
/** | ||
* A `for...of` statement. | ||
* | ||
* @see {@linkcode ForXStatement} | ||
* | ||
* @extends {ForXStatement} | ||
*/ | ||
interface ForOfStatement extends ForXStatement { | ||
/** | ||
* Info from the ecosystem. | ||
* | ||
* @see {@linkcode ForOfStatementData} | ||
*/ | ||
data?: Optional<ForOfStatementData> | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'forOfStatement' | ||
} | ||
|
||
export type { ForOfStatementData, ForOfStatement 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* @file Nodes - ForXStatement | ||
* @module esast/nodes/ForXStatement | ||
*/ | ||
|
||
import type { | ||
Expression, | ||
Parent, | ||
Pattern, | ||
Statement, | ||
VariableDeclaration | ||
} from '@flex-development/esast' | ||
|
||
/** | ||
* A `for...of` or `for...in` statement. | ||
* | ||
* @see {@linkcode Parent} | ||
* | ||
* @extends {Parent} | ||
*/ | ||
interface ForXStatement extends Parent { | ||
/** | ||
* List of children. | ||
* | ||
* @see {@linkcode Expression} | ||
* @see {@linkcode Pattern} | ||
* @see {@linkcode Statement} | ||
* @see {@linkcode VariableDeclaration} | ||
*/ | ||
children: [ | ||
left: Pattern | VariableDeclaration, | ||
right: Expression, | ||
body: Statement | ||
] | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: `for${Uppercase<string>}${string}` | ||
} | ||
|
||
export type { ForXStatement as default } |