-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed6f03c
commit 051aae3
Showing
14 changed files
with
539 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
convert/src/__test__/integration-tests/enums.integration.ts
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,17 @@ | ||
import { convertDeployExecute } from "../utility"; | ||
jest.setTimeout(99999999); | ||
|
||
describe("when converting enums", () => { | ||
it("will execute compareEnum as if it were node", async () => { | ||
const resultFromSfn = await convertDeployExecute("enums", "compareEnum"); | ||
const { compareEnum } = require("../resources/enums"); | ||
const resultFromNode = await compareEnum(); | ||
expect(resultFromSfn).toEqual(resultFromNode); | ||
}); | ||
it("will execute compareStringEnum as if it were node", async () => { | ||
const resultFromSfn = await convertDeployExecute("enums", "compareStringEnum"); | ||
const { compareStringEnum } = require("../resources/enums"); | ||
const resultFromNode = await compareStringEnum(); | ||
expect(resultFromSfn).toEqual(resultFromNode); | ||
}); | ||
}); |
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 @@ | ||
{ | ||
"StartAt": "Initialize", | ||
"States": { | ||
"Initialize": { | ||
"Type": "Pass", | ||
"ResultPath": "$", | ||
"Parameters": { | ||
"vars.$": "$$.Execution.Input", | ||
"_undefined": null | ||
}, | ||
"Next": "Assign x" | ||
}, | ||
"Assign x": { | ||
"Type": "Pass", | ||
"ResultPath": "$.vars.x", | ||
"Result": 0, | ||
"Next": "If (x === ExampleEnum.A)" | ||
}, | ||
"If (x === ExampleEnum.A)": { | ||
"Type": "Choice", | ||
"Choices": [ | ||
{ | ||
"Variable": "$.vars.x", | ||
"NumericEquals": 0, | ||
"Next": "Return \"success\"" | ||
} | ||
], | ||
"Default": "Return \"fail\"" | ||
}, | ||
"Return \"success\"": { | ||
"End": true, | ||
"Type": "Pass", | ||
"Result": "success" | ||
}, | ||
"Return \"fail\"": { | ||
"End": true, | ||
"Type": "Pass", | ||
"Result": "fail" | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
convert/src/__test__/output/asl/enums-compareStringEnum.json
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 @@ | ||
{ | ||
"StartAt": "Initialize", | ||
"States": { | ||
"Initialize": { | ||
"Type": "Pass", | ||
"ResultPath": "$", | ||
"Parameters": { | ||
"vars.$": "$$.Execution.Input", | ||
"_undefined": null | ||
}, | ||
"Next": "Assign x" | ||
}, | ||
"Assign x": { | ||
"Type": "Pass", | ||
"ResultPath": "$.vars.x", | ||
"Result": "a", | ||
"Next": "If (x === ExampleEnumStri ..." | ||
}, | ||
"If (x === ExampleEnumStri ...": { | ||
"Type": "Choice", | ||
"Choices": [ | ||
{ | ||
"Variable": "$.vars.x", | ||
"StringEquals": "a", | ||
"Next": "Return \"success\"" | ||
} | ||
], | ||
"Default": "Return \"fail\"" | ||
}, | ||
"Return \"success\"": { | ||
"End": true, | ||
"Type": "Pass", | ||
"Result": "success" | ||
}, | ||
"Return \"fail\"": { | ||
"End": true, | ||
"Type": "Pass", | ||
"Result": "fail" | ||
} | ||
} | ||
} |
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,64 @@ | ||
{ | ||
"statements": [ | ||
{ | ||
"name": { | ||
"identifier": "x", | ||
"_syntaxKind": "identifier", | ||
"type": "unknown" | ||
}, | ||
"expression": { | ||
"stateName": "Assign x", | ||
"parameters": { | ||
"value": 0, | ||
"type": "numeric", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "asl-pass-state" | ||
}, | ||
"stateName": "Assign x", | ||
"_syntaxKind": "variable-assignment" | ||
}, | ||
{ | ||
"stateName": "If (x === ExampleEnum.A)", | ||
"condition": { | ||
"lhs": { | ||
"identifier": "x", | ||
"_syntaxKind": "identifier", | ||
"type": "unknown" | ||
}, | ||
"operator": "eq", | ||
"rhs": { | ||
"value": 0, | ||
"type": "numeric", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "binary-expression" | ||
}, | ||
"then": { | ||
"statements": [ | ||
{ | ||
"expression": { | ||
"value": "success", | ||
"type": "string", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "return", | ||
"stateName": "Return \"success\"" | ||
} | ||
], | ||
"_syntaxKind": "function" | ||
}, | ||
"_syntaxKind": "if" | ||
}, | ||
{ | ||
"expression": { | ||
"value": "fail", | ||
"type": "string", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "return", | ||
"stateName": "Return \"fail\"" | ||
} | ||
], | ||
"_syntaxKind": "statemachine" | ||
} |
64 changes: 64 additions & 0 deletions
64
convert/src/__test__/output/iasl/enums-compareStringEnum.json
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,64 @@ | ||
{ | ||
"statements": [ | ||
{ | ||
"name": { | ||
"identifier": "x", | ||
"_syntaxKind": "identifier", | ||
"type": "unknown" | ||
}, | ||
"expression": { | ||
"stateName": "Assign x", | ||
"parameters": { | ||
"value": "a", | ||
"type": "string", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "asl-pass-state" | ||
}, | ||
"stateName": "Assign x", | ||
"_syntaxKind": "variable-assignment" | ||
}, | ||
{ | ||
"stateName": "If (x === ExampleEnumStri ...", | ||
"condition": { | ||
"lhs": { | ||
"identifier": "x", | ||
"_syntaxKind": "identifier", | ||
"type": "unknown" | ||
}, | ||
"operator": "eq", | ||
"rhs": { | ||
"value": "a", | ||
"type": "string", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "binary-expression" | ||
}, | ||
"then": { | ||
"statements": [ | ||
{ | ||
"expression": { | ||
"value": "success", | ||
"type": "string", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "return", | ||
"stateName": "Return \"success\"" | ||
} | ||
], | ||
"_syntaxKind": "function" | ||
}, | ||
"_syntaxKind": "if" | ||
}, | ||
{ | ||
"expression": { | ||
"value": "fail", | ||
"type": "string", | ||
"_syntaxKind": "literal" | ||
}, | ||
"_syntaxKind": "return", | ||
"stateName": "Return \"fail\"" | ||
} | ||
], | ||
"_syntaxKind": "statemachine" | ||
} |
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,34 @@ | ||
import * as asl from "@ts2asl/asl-lib" | ||
|
||
enum ExampleEnum { | ||
"A", | ||
"B" | ||
} | ||
|
||
export const compareEnum = asl.deploy.asStateMachine(async () =>{ | ||
const x = asl.pass({ | ||
name: "Assign x", | ||
parameters: () => 0 | ||
}); | ||
asl.typescriptIf({ | ||
name: "If (x === ExampleEnum.A)", | ||
condition: () => x === 0, | ||
then: async () => { | ||
return "success"; | ||
} | ||
}) | ||
return "fail"; | ||
}); | ||
|
||
enum ExampleEnumString { | ||
"A" = "a", | ||
"B" = "b" | ||
} | ||
|
||
export const compareStringEnum = asl.deploy.asStateMachine(async () => { | ||
const x = ExampleEnumString.A; | ||
if (x === ExampleEnumString.A) { | ||
return "success" | ||
} | ||
return "fail" | ||
}); |
34 changes: 34 additions & 0 deletions
34
convert/src/__test__/output/ts-lib/enums-compareStringEnum.ts
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,34 @@ | ||
import * as asl from "@ts2asl/asl-lib" | ||
|
||
enum ExampleEnum { | ||
"A", | ||
"B" | ||
} | ||
|
||
export const compareEnum = asl.deploy.asStateMachine(async () => { | ||
const x = ExampleEnum.A; | ||
if (x === ExampleEnum.A) { | ||
return "success" | ||
} | ||
return "fail" | ||
}); | ||
|
||
enum ExampleEnumString { | ||
"A" = "a", | ||
"B" = "b" | ||
} | ||
|
||
export const compareStringEnum = asl.deploy.asStateMachine(async () =>{ | ||
const x = asl.pass({ | ||
name: "Assign x", | ||
parameters: () => "a" | ||
}); | ||
asl.typescriptIf({ | ||
name: "If (x === ExampleEnumStri ...", | ||
condition: () => x === "a", | ||
then: async () => { | ||
return "success"; | ||
} | ||
}) | ||
return "fail"; | ||
}); |
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,27 @@ | ||
import * as asl from "@ts2asl/asl-lib" | ||
|
||
enum ExampleEnum { | ||
"A", | ||
"B" | ||
} | ||
|
||
export const compareEnum = asl.deploy.asStateMachine(async () => { | ||
const x = ExampleEnum.A; | ||
if (x === ExampleEnum.A) { | ||
return "success" | ||
} | ||
return "fail" | ||
}); | ||
|
||
enum ExampleEnumString { | ||
"A" = "a", | ||
"B" = "b" | ||
} | ||
|
||
export const compareStringEnum = asl.deploy.asStateMachine(async () => { | ||
const x = ExampleEnumString.A; | ||
if (x === ExampleEnumString.A) { | ||
return "success" | ||
} | ||
return "fail" | ||
}); |
Oops, something went wrong.