-
-
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
b832ad1
commit 17ab0b9
Showing
5 changed files
with
113 additions
and
2 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,48 @@ | ||
/** | ||
* @file Type Tests - IfStatement | ||
* @module esast/nodes/tests/unit-d/IfStatement | ||
*/ | ||
|
||
import type { | ||
Data, | ||
Expression, | ||
Parent, | ||
Statement | ||
} from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../statement-if' | ||
|
||
describe('unit-d:nodes/IfStatement', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.IfStatementData | ||
|
||
it('should extend Parent', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<Parent>() | ||
}) | ||
|
||
it('should match [children: [Expression, Statement, Statement] | [Expression, Statement]]', () => { | ||
// Arrange | ||
type Expect = [Expression, Statement, Statement] | [Expression, Statement] | ||
|
||
// Expect | ||
expectTypeOf<Subject>().toHaveProperty('children').toEqualTypeOf<Expect>() | ||
}) | ||
|
||
it('should match [data?: Optional<IfStatementData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [type: "ifStatement"]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('type') | ||
.toEqualTypeOf<'ifStatement'>() | ||
}) | ||
|
||
describe('IfStatementData', () => { | ||
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
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,54 @@ | ||
/** | ||
* @file Nodes - IfStatement | ||
* @module esast/nodes/IfStatement | ||
*/ | ||
|
||
import type { | ||
Data, | ||
Expression, | ||
Parent, | ||
Statement | ||
} from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with `if` statements. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface IfStatementData extends Data {} | ||
|
||
/** | ||
* An `if` statement. | ||
* | ||
* @see {@linkcode Parent} | ||
* | ||
* @extends {Parent} | ||
*/ | ||
interface IfStatement extends Parent { | ||
/** | ||
* List of children. | ||
* | ||
* @see {@linkcode Expression} | ||
* @see {@linkcode Statement} | ||
*/ | ||
children: | ||
| [test: Expression, consequent: Statement, alternate: Statement] | ||
| [test: Expression, consequent: Statement] | ||
|
||
/** | ||
* Info from the ecosystem. | ||
* | ||
* @see {@linkcode IfStatementData} | ||
*/ | ||
data?: Optional<IfStatementData> | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'ifStatement' | ||
} | ||
|
||
export type { IfStatementData, IfStatement as default } |