Skip to content

Commit

Permalink
feat(nodes): ContinueStatement
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Mar 8, 2024
1 parent 2672b3d commit 3c00819
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 0 deletions.
21 changes: 21 additions & 0 deletions __tests__/setup/index.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare module '@flex-development/esast' {
const LITERAL: unique symbol
const NODE: unique symbol
const PARENT: unique symbol

interface Literal {
literal: typeof LITERAL
}

interface Node {
node: typeof NODE
}

interface Parent {
parent: typeof PARENT
}

export { NODE }
}

export {}
6 changes: 6 additions & 0 deletions src/content/__tests__/statement.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { NodeObject } from '#tests/types'
import type {
BlockStatement,
BreakStatement,
ContinueStatement,
EmptyStatement
} from '@flex-development/esast'
import type * as TestSubject from '../statement'
Expand All @@ -30,6 +31,11 @@ describe('unit-d:content/statement', () => {
.toMatchTypeOf<NodeObject<BreakStatement>>()
})

it('should match NodeObject<ContinueStatement>', () => {
expectTypeOf<TestSubject.StatementMap>()
.toMatchTypeOf<NodeObject<ContinueStatement>>()
})

it('should match NodeObject<EmptyStatement>', () => {
expectTypeOf<TestSubject.StatementMap>()
.toMatchTypeOf<NodeObject<EmptyStatement>>()
Expand Down
2 changes: 2 additions & 0 deletions src/content/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type {
BlockStatement,
BreakStatement,
ContinueStatement,
EmptyStatement
} from '@flex-development/esast'

Expand All @@ -32,6 +33,7 @@ type Statement = StatementMap[keyof StatementMap]
interface StatementMap {
blockStatement: BlockStatement
breakStatement: BreakStatement
continueStatement: ContinueStatement
emptyStatement: EmptyStatement
}

Expand Down
41 changes: 41 additions & 0 deletions src/nodes/__tests__/statement-continue.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file Type Tests - ContinueStatement
* @module esast/nodes/tests/unit-d/ContinueStatement
*/

import type { Data, Identifier, Parent } from '@flex-development/esast'
import type { EmptyArray, Optional } from '@flex-development/tutils'
import type * as TestSubject from '../statement-continue'

describe('unit-d:nodes/ContinueStatement', () => {
type Subject = TestSubject.default
type SubjectData = TestSubject.ContinueStatementData

it('should extend Parent', () => {
expectTypeOf<Subject>().toMatchTypeOf<Parent>()
})

it('should match [children: EmptyArray | [Identifier]]', () => {
expectTypeOf<Subject>()
.toHaveProperty('children')
.toEqualTypeOf<EmptyArray | [Identifier]>()
})

it('should match [data?: Optional<ContinueStatementData>]', () => {
expectTypeOf<Subject>()
.toHaveProperty('data')
.toEqualTypeOf<Optional<SubjectData>>()
})

it('should match [type: "continueStatement"]', () => {
expectTypeOf<Subject>()
.toHaveProperty('type')
.toEqualTypeOf<'continueStatement'>()
})

describe('ContinueStatementData', () => {
it('should extend Data', () => {
expectTypeOf<SubjectData>().toMatchTypeOf<Data>()
})
})
})
4 changes: 4 additions & 0 deletions src/nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export type {
default as BreakStatement,
BreakStatementData
} from './statement-break'
export type {
default as ContinueStatement,
ContinueStatementData
} from './statement-continue'
export type {
default as EmptyStatement,
EmptyStatementData
Expand Down
46 changes: 46 additions & 0 deletions src/nodes/statement-continue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @file Nodes - ContinueStatement
* @module esast/nodes/ContinueStatement
*/

import type { Data, Identifier, Parent } from '@flex-development/esast'
import type { EmptyArray, Optional } from '@flex-development/tutils'

/**
* Info associated with `continue` statements.
*
* @see {@linkcode Data}
*
* @extends {Data}
*/
interface ContinueStatementData extends Data {}

/**
* A `continue` statement.
*
* @see {@linkcode Parent}
*
* @extends {Parent}
*/
interface ContinueStatement extends Parent {
/**
* List of children.
*
* @see {@linkcode Identifier}
*/
children: EmptyArray | [label: Identifier]

/**
* Info from the ecosystem.
*
* @see {@linkcode ContinueStatementData}
*/
data?: Optional<ContinueStatementData>

/**
* Node type.
*/
type: 'continueStatement'
}

export type { ContinueStatementData, ContinueStatement as default }

0 comments on commit 3c00819

Please sign in to comment.