From 41fabd5794af992f8edb2db97cf3d62bbd6d8635 Mon Sep 17 00:00:00 2001 From: Ananthu C V Date: Mon, 2 Oct 2023 16:48:06 +0530 Subject: [PATCH] feat(sdk): adding std.Map tests (#4336) This is the first time I am writing tests, so admittedly my tests are not that versatile. But as I also believe that std tests should be straightforward, I do not totally mind it. Since `keys()` and `values()` methods of maps seems to return an array that fails to assert "is the same as another array of same elements" (which seems to be a [bug](https://github.com/winglang/wing/issues/4118)), I had to iterate over the array values and confirm it works as expected. closes: #4363 ## Checklist - [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [ ] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- examples/tests/invalid/container_types.test.w | 4 + .../invalid/immutable_container_types.test.w | 10 +- examples/tests/sdk_tests/std/map.test.w | 241 ++++++ tools/hangar/__snapshots__/invalid.ts.snap | 56 ++ .../std/map.test.w_compile_tf-aws.md | 692 ++++++++++++++++++ .../sdk_tests/std/map.test.w_test_sim.md | 15 +- 6 files changed, 1015 insertions(+), 3 deletions(-) diff --git a/examples/tests/invalid/container_types.test.w b/examples/tests/invalid/container_types.test.w index fa1050c24b8..f7ebd42fc09 100644 --- a/examples/tests/invalid/container_types.test.w +++ b/examples/tests/invalid/container_types.test.w @@ -26,3 +26,7 @@ s1.someRandomMethod(); let a: Array = MutArray[]; // ^^^^^^^^^^^^^^^ Expected type to be "Array", but got "MutArray" instead + +let mm1: MutMap = { "a" => 1, "b" => 2, "c" => 3 }; +let mm2 = MutMap { "a" => 1, "b" => 2, "c" => 3 }; +let mm3 = mm2.copyMut(); \ No newline at end of file diff --git a/examples/tests/invalid/immutable_container_types.test.w b/examples/tests/invalid/immutable_container_types.test.w index ba5e3087b79..8783386a600 100644 --- a/examples/tests/invalid/immutable_container_types.test.w +++ b/examples/tests/invalid/immutable_container_types.test.w @@ -1,4 +1,12 @@ let m1 = Map{"a" => "hi"}; m1.set("a", "bye"); -// ^^^ Unknown symbol "set" (TODO: better error message https://github.com/winglang/wing/issues/1660) \ No newline at end of file +// ^^^ Unknown symbol "set" (TODO: better error message https://github.com/winglang/wing/issues/1660) + +let m2: Map = MutMap {}; +let m3 = Map { "a" => "A" }; +let m4 = {"1" => 1, "2" => 2 }; +m4.set("2", 3); +let m5 = m4.copy(); +m4.delete("1"); +m4.clear(); \ No newline at end of file diff --git a/examples/tests/sdk_tests/std/map.test.w b/examples/tests/sdk_tests/std/map.test.w index a0e71b2113c..bcd86f1cacd 100644 --- a/examples/tests/sdk_tests/std/map.test.w +++ b/examples/tests/sdk_tests/std/map.test.w @@ -15,3 +15,244 @@ let mvalues = m.values(); assert(mvalues.length == 2); assert(mvalues.at(0) == 123); assert(mvalues.at(1) == 99); + +// container types are equal regardless of the mutability if they have the same +// content but in all scenraios the type is specified for better readability + +assert(Map{} == MutMap{}); + +test "equality"{ + assert(Map{} == MutMap{}); +} + + +let apprentices = MutMap { "plagueis" => "sidious", "dooku" => "ventress" }; +apprentices.delete("plagueis"); +assert(apprentices.size() == 1); +assert(apprentices.copy() == Map {"dooku" => "ventress"}); +apprentices.set("sidious", "dooku"); +assert(apprentices.get("sidious") == "dooku"); +apprentices.set("sidious", "maul"); +assert(apprentices.get("sidious") == "maul"); +apprentices.clear(); +assert(apprentices == MutMap{}); + +test "mutability" { + let apprentices = MutMap { "plagueis" => "sidious", "dooku" => "ventress" }; + apprentices.delete("plagueis"); + assert(apprentices.size() == 1); + assert(apprentices.copy() == Map {"dooku" => "ventress"}); + apprentices.set("sidious", "dooku"); + assert(apprentices.get("sidious") == "dooku"); + apprentices.set("sidious", "maul"); + assert(apprentices.get("sidious") == "maul"); + apprentices.clear(); + assert(apprentices == MutMap{}); +} + + +let trilogies = { "PT" => 2, "OT" => 1, "ST" => 3 }; +assert(trilogies.size() == 3); + +let mutTrilogies = MutMap { "PT" => 2, "OT" => 1, "ST" => 3 }; +assert(mutTrilogies.size() == 3); +mutTrilogies.delete("ST"); // One could argue that it's better if this does not exist +assert(mutTrilogies.size() == 2); + +test "size()" { + let trilogies = { "PT" => 2, "OT" => 1, "ST" => 3 }; + assert(trilogies.size() == 3); + + let mutTrilogies = MutMap { "PT" => 2, "OT" => 1, "ST" => 3 }; + assert(mutTrilogies.size() == 3); + mutTrilogies.delete("ST"); + assert(mutTrilogies.size() == 2); +} + + +let greeting = { "hello" => "there!" }; +assert(greeting.get("hello") == "there!"); + +let general: str? = greeting.get("grievous"); +assert(general == nil); + +let mutGreeting = MutMap{ "general" => "kenobi" }; +assert(mutGreeting.get("general") == "kenobi"); + +let Viceroy: str? = mutGreeting.get("gunray"); +assert(Viceroy == nil); + +test "get()" { + let greeting = { "hello" => "there!" }; + assert(greeting.get("hello") == "there!"); + + let general: str? = greeting.get("grievous"); + assert(general == nil); + + let mutGreeting = MutMap{ "general" => "kenobi" }; + assert(mutGreeting.get("general") == "kenobi"); + + let Viceroy: str? = mutGreeting.get("gunray"); + assert(Viceroy == nil); +} + + +let legion501 = { "fives" => "CT-5555", "rex" => "CT-7567" , "appo" => "CC-1119", "jesse" => "CT-5597" }; +assert(legion501.has("fives") == true); +assert(legion501.has("rex") == legion501.has("jesse")); +assert(legion501.has("cody") == false); + +let padawans = MutMap { "ahsoka" => "anakin", "anakin" => "kenobi", "kenobi" => "qui gon", "qui gon" => "dooku", "dooku" => "yoda" }; +assert(padawans.has("anakin") == true); +assert(padawans.has("qui gon") == padawans.has("dooku") == padawans.has("anakin")); +assert(padawans.has("windu") == padawans.has("sifo dyas")); +assert(padawans.has("revan") == false); + +test "has()" { + let legion501 = { "fives" => "CT-5555", "rex" => "CT-7567" , "appo" => "CC-1119", "jesse" => "CT-5597" }; + assert(legion501.has("fives") == true); + assert(legion501.has("rex") == legion501.has("jesse")); + assert(legion501.has("cody") == false); + + let padawans = MutMap { "ahsoka" => "anakin", "anakin" => "kenobi", "kenobi" => "qui gon", "qui gon" => "dooku", "dooku" => "yoda" }; + assert(padawans.has("anakin") == true); + assert(padawans.has("qui gon") == padawans.has("dooku") == padawans.has("anakin")); + assert(padawans.has("windu") == padawans.has("sifo dyas")); + assert(padawans.has("revan") == false); +} + + +let forceUsers = { "sith" => ["malak", "vader", "bane"], "jedi" => ["sunrider", "bastila", "bindo"]}; +let userKeys = forceUsers.values(); +let valArr = [["malak", "vader", "bane"], ["sunrider", "bastila", "bindo"]]; +assert(userKeys.length == valArr.length); +for i in 0..userKeys.length { + assert(userKeys.at(i) == valArr.at(i)); +} + +let saberforms = MutMap { "1st" => "shii-cho", "2nd" => "makashi", "3rd" => "soresu", "4th" => "ataru", "5th" => "shien", "6th" => "niman", "7th" => "juyo"}; +let saberformNames = saberforms.values(); +let nameArr = ["shii-cho", "makashi", "soresu", "ataru", "shien", "niman", "juyo"]; +assert(saberformNames.length == nameArr.length); +for i in 0..saberformNames.length { + assert(saberformNames.at(i) == nameArr.at(i)); +} + +test "values()" { + let forceUsers = { "sith" => ["malak", "vader", "bane"], "jedi" => ["sunrider", "bastila", "bindo"]}; + let userKeys = forceUsers.values(); + let valArr = [["malak", "vader", "bane"], ["sunrider", "bastila", "bindo"]]; + assert(userKeys.length == valArr.length); + for i in 0..userKeys.length { + assert(userKeys.at(i) == valArr.at(i)); + } + + let saberforms = MutMap { "1st" => "shii-cho", "2nd" => "makashi", "3rd" => "soresu", "4th" => "ataru", "5th" => "shien", "6th" => "niman", "7th" => "juyo"}; + let saberformNames = saberforms.values(); + let nameArr = ["shii-cho", "makashi", "soresu", "ataru", "shien", "niman", "juyo"]; + assert(saberformNames.length == nameArr.length); + for i in 0..saberformNames.length { + assert(saberformNames.at(i) == nameArr.at(i)); + } +} + + +let lightsaberColorMap = { "red" => "sith", "blue" => "jedi" }; +let lightsaberColors = lightsaberColorMap.keys(); +let colorArr = ["red", "blue"]; +assert(lightsaberColors.length == colorArr.length); +for i in 0..lightsaberColors.length { + assert(lightsaberColors.at(i) == colorArr.at(i)); +} + +let isMandalorianWarrior = MutMap { "bo katan" => true, "jango" => true, "satine" => false, "boba" => true}; +let mandalorianKeys = isMandalorianWarrior.keys(); +let keysArr = ["bo katan", "jango", "satine", "boba"]; +assert(mandalorianKeys.length == keysArr.length); +for i in 0..mandalorianKeys.length { + assert(mandalorianKeys.at(i) == keysArr.at(i)); +} + +test "keys()" { + let lightsaberColorMap = { "red" => "sith", "blue" => "jedi" }; + let lightsaberColors = lightsaberColorMap.keys(); + let colorArr = ["red", "blue"]; + assert(lightsaberColors.length == colorArr.length); + for i in 0..lightsaberColors.length { + assert(lightsaberColors.at(i) == colorArr.at(i)); + } + + let isMandalorianWarrior = MutMap { "bo katan" => true, "jango" => true, "satine" => false, "boba" => true}; + let mandalorianKeys = isMandalorianWarrior.keys(); + let keysArr = ["bo katan", "jango", "satine", "boba"]; + assert(mandalorianKeys.length == keysArr.length); + for i in 0..mandalorianKeys.length { + assert(mandalorianKeys.at(i) == keysArr.at(i)); + } + +} + + +let ruleOfTwo = { "master" => "apprentice" }; +let mutRuleOfTwo: MutMap = ruleOfTwo.copyMut(); +assert(mutRuleOfTwo.copy() == ruleOfTwo); +assert(mutRuleOfTwo.delete("master") == true); +assert(mutRuleOfTwo.size() == 0); + +test "copyMut()" { + let ruleOfTwo = { "master" => "apprentice" }; + let mutRuleOfTwo: MutMap = ruleOfTwo.copyMut(); + assert(mutRuleOfTwo.copy() == ruleOfTwo); + assert(mutRuleOfTwo.delete("master") == true); + assert(mutRuleOfTwo.size() == 0); +} + + +let authority = MutMap {"republic" => "senate", "empire" => "emperor"}; +let immutAuthority: Map = authority.copy(); +assert(immutAuthority.copyMut() == authority); + +test "copy()" { + let authority = MutMap {"republic" => "senate", "empire" => "emperor"}; + let immutAuthority: Map = authority.copy(); + assert(immutAuthority.copyMut() == authority); +} + + +let senate = MutMap {"chancellor" => "palpatine"}; // I love democracy +senate.set("senator", "organa"); +assert(senate.get("senator") == "organa"); +assert(senate.size() == 2); + +test "set()" { + let senate = MutMap {"chancellor" => "palpatine"}; + senate.set("senator", "organa"); + assert(senate.get("senator") == "organa"); + assert(senate.size() == 2); +} + + +let position = MutMap {"librarian" => "jocasta"}; +position.clear(); +assert(position.size() == 0); + +test "clear()" { + let position = MutMap {"librarian" => "jocasta"}; + position.clear(); + assert(position.size() == 0); +} + + +let sithTriumvirate = MutMap { "traya" => "lord of betrayal", "nihilus" => "lord of hunger", "sion" => "lord of pain" }; +sithTriumvirate.delete("nihilus"); +assert(sithTriumvirate.size() == 2); +sithTriumvirate.delete("sion"); +assert(sithTriumvirate == MutMap { "traya" => "lord of betrayal" }); + +test "delete()" { + let sithTriumvirate = MutMap { "traya" => "lord of betrayal", "nihilus" => "lord of hunger", "sion" => "lord of pain" }; + sithTriumvirate.delete("nihilus"); + assert(sithTriumvirate.size() == 2); + sithTriumvirate.delete("sion"); + assert(sithTriumvirate == MutMap { "traya" => "lord of betrayal" }); +} diff --git a/tools/hangar/__snapshots__/invalid.ts.snap b/tools/hangar/__snapshots__/invalid.ts.snap index 783b0271e93..63b6451fbbc 100644 --- a/tools/hangar/__snapshots__/invalid.ts.snap +++ b/tools/hangar/__snapshots__/invalid.ts.snap @@ -854,6 +854,20 @@ error: Expected type to be \\"Array\\", but got \\"MutArray\\" instead | ^^^^^^^^^^^^^^^ Expected type to be \\"Array\\", but got \\"MutArray\\" instead +error: Expected type to be \\"MutMap\\", but got \\"Map\\" instead + --> ../../../examples/tests/invalid/container_types.test.w:30:24 + | +30 | let mm1: MutMap = { \\"a\\" => 1, \\"b\\" => 2, \\"c\\" => 3 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Expected type to be \\"MutMap\\", but got \\"Map\\" instead + + +error: Unknown symbol \\"copyMut\\" + --> ../../../examples/tests/invalid/container_types.test.w:32:15 + | +32 | let mm3 = mm2.copyMut(); + | ^^^^^^^ Unknown symbol \\"copyMut\\" + + Tests 1 failed (1) @@ -1164,6 +1178,48 @@ exports[`immutable_container_types.test.w 1`] = ` | ^^^ Unknown symbol \\"set\\" +error: Expected type to be \\"Map\\", but got \\"MutMap\\" instead + --> ../../../examples/tests/invalid/immutable_container_types.test.w:6:20 + | +6 | let m2: Map = MutMap {}; + | ^^^^^^^^^^^^^^ Expected type to be \\"Map\\", but got \\"MutMap\\" instead + + +error: Expected type to be \\"bool\\", but got \\"str\\" instead + --> ../../../examples/tests/invalid/immutable_container_types.test.w:7:29 + | +7 | let m3 = Map { \\"a\\" => \\"A\\" }; + | ^^^ Expected type to be \\"bool\\", but got \\"str\\" instead + + +error: Unknown symbol \\"set\\" + --> ../../../examples/tests/invalid/immutable_container_types.test.w:9:4 + | +9 | m4.set(\\"2\\", 3); + | ^^^ Unknown symbol \\"set\\" + + +error: Unknown symbol \\"copy\\" + --> ../../../examples/tests/invalid/immutable_container_types.test.w:10:13 + | +10 | let m5 = m4.copy(); + | ^^^^ Unknown symbol \\"copy\\" + + +error: Unknown symbol \\"delete\\" + --> ../../../examples/tests/invalid/immutable_container_types.test.w:11:4 + | +11 | m4.delete(\\"1\\"); + | ^^^^^^ Unknown symbol \\"delete\\" + + +error: Unknown symbol \\"clear\\" + --> ../../../examples/tests/invalid/immutable_container_types.test.w:12:4 + | +12 | m4.clear(); + | ^^^^^ Unknown symbol \\"clear\\" + + Tests 1 failed (1) diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_compile_tf-aws.md index 5f64981a824..171d4ca9293 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_compile_tf-aws.md @@ -1,5 +1,291 @@ # [map.test.w](../../../../../../examples/tests/sdk_tests/std/map.test.w) | compile | tf-aws +## inflight.$Closure1-1.js +```js +module.exports = function({ }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + {((cond) => {if (!cond) throw new Error("assertion failed: Map{} == MutMap{}")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(({}),({}))))}; + } + } + return $Closure1; +} + +``` + +## inflight.$Closure10-1.js +```js +module.exports = function({ }) { + class $Closure10 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const senate = ({"chancellor": "palpatine"}); + ((obj, args) => { obj[args[0]] = args[1]; })(senate, ["senator","organa"]); + {((cond) => {if (!cond) throw new Error("assertion failed: senate.get(\"senator\") == \"organa\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((senate)["senator"],"organa")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: senate.size() == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(senate).length,2)))}; + } + } + return $Closure10; +} + +``` + +## inflight.$Closure11-1.js +```js +module.exports = function({ }) { + class $Closure11 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const position = ({"librarian": "jocasta"}); + ((map) => { for(const k in map){delete map[k]}; })(position); + {((cond) => {if (!cond) throw new Error("assertion failed: position.size() == 0")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(position).length,0)))}; + } + } + return $Closure11; +} + +``` + +## inflight.$Closure12-1.js +```js +module.exports = function({ }) { + class $Closure12 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const sithTriumvirate = ({"traya": "lord of betrayal","nihilus": "lord of hunger","sion": "lord of pain"}); + (delete (sithTriumvirate)["nihilus"]); + {((cond) => {if (!cond) throw new Error("assertion failed: sithTriumvirate.size() == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(sithTriumvirate).length,2)))}; + (delete (sithTriumvirate)["sion"]); + {((cond) => {if (!cond) throw new Error("assertion failed: sithTriumvirate == MutMap { \"traya\" => \"lord of betrayal\" }")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(sithTriumvirate,({"traya": "lord of betrayal"}))))}; + } + } + return $Closure12; +} + +``` + +## inflight.$Closure2-1.js +```js +module.exports = function({ }) { + class $Closure2 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const apprentices = ({"plagueis": "sidious","dooku": "ventress"}); + (delete (apprentices)["plagueis"]); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.size() == 1")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(apprentices).length,1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.copy() == Map {\"dooku\" => \"ventress\"}")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(({...(apprentices)}),({"dooku": "ventress"}))))}; + ((obj, args) => { obj[args[0]] = args[1]; })(apprentices, ["sidious","dooku"]); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.get(\"sidious\") == \"dooku\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((apprentices)["sidious"],"dooku")))}; + ((obj, args) => { obj[args[0]] = args[1]; })(apprentices, ["sidious","maul"]); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.get(\"sidious\") == \"maul\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((apprentices)["sidious"],"maul")))}; + ((map) => { for(const k in map){delete map[k]}; })(apprentices); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices == MutMap{}")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(apprentices,({}))))}; + } + } + return $Closure2; +} + +``` + +## inflight.$Closure3-1.js +```js +module.exports = function({ }) { + class $Closure3 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const trilogies = ({"PT": 2,"OT": 1,"ST": 3}); + {((cond) => {if (!cond) throw new Error("assertion failed: trilogies.size() == 3")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(trilogies).length,3)))}; + const mutTrilogies = ({"PT": 2,"OT": 1,"ST": 3}); + {((cond) => {if (!cond) throw new Error("assertion failed: mutTrilogies.size() == 3")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(mutTrilogies).length,3)))}; + (delete (mutTrilogies)["ST"]); + {((cond) => {if (!cond) throw new Error("assertion failed: mutTrilogies.size() == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(mutTrilogies).length,2)))}; + } + } + return $Closure3; +} + +``` + +## inflight.$Closure4-1.js +```js +module.exports = function({ }) { + class $Closure4 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const greeting = ({"hello": "there!"}); + {((cond) => {if (!cond) throw new Error("assertion failed: greeting.get(\"hello\") == \"there!\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((greeting)["hello"],"there!")))}; + const general = (greeting)["grievous"]; + {((cond) => {if (!cond) throw new Error("assertion failed: general == nil")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(general,undefined)))}; + const mutGreeting = ({"general": "kenobi"}); + {((cond) => {if (!cond) throw new Error("assertion failed: mutGreeting.get(\"general\") == \"kenobi\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((mutGreeting)["general"],"kenobi")))}; + const Viceroy = (mutGreeting)["gunray"]; + {((cond) => {if (!cond) throw new Error("assertion failed: Viceroy == nil")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Viceroy,undefined)))}; + } + } + return $Closure4; +} + +``` + +## inflight.$Closure5-1.js +```js +module.exports = function({ }) { + class $Closure5 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const legion501 = ({"fives": "CT-5555","rex": "CT-7567","appo": "CC-1119","jesse": "CT-5597"}); + {((cond) => {if (!cond) throw new Error("assertion failed: legion501.has(\"fives\") == true")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("fives" in (legion501)),true)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: legion501.has(\"rex\") == legion501.has(\"jesse\")")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("rex" in (legion501)),("jesse" in (legion501)))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: legion501.has(\"cody\") == false")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("cody" in (legion501)),false)))}; + const padawans = ({"ahsoka": "anakin","anakin": "kenobi","kenobi": "qui gon","qui gon": "dooku","dooku": "yoda"}); + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"anakin\") == true")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("anakin" in (padawans)),true)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"qui gon\") == padawans.has(\"dooku\") == padawans.has(\"anakin\")")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("qui gon" in (padawans)),("dooku" in (padawans)))),("anakin" in (padawans)))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"windu\") == padawans.has(\"sifo dyas\")")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("windu" in (padawans)),("sifo dyas" in (padawans)))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"revan\") == false")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("revan" in (padawans)),false)))}; + } + } + return $Closure5; +} + +``` + +## inflight.$Closure6-1.js +```js +module.exports = function({ }) { + class $Closure6 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const forceUsers = ({"sith": ["malak", "vader", "bane"],"jedi": ["sunrider", "bastila", "bindo"]}); + const userKeys = Object.values(forceUsers); + const valArr = [["malak", "vader", "bane"], ["sunrider", "bastila", "bindo"]]; + {((cond) => {if (!cond) throw new Error("assertion failed: userKeys.length == valArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(userKeys.length,valArr.length)))}; + for (const i of ((s,e,i) => { function* iterator(start,end,inclusive) { let i = start; let limit = inclusive ? ((end < start) ? end - 1 : end + 1) : end; while (i < limit) yield i++; while (i > limit) yield i--; }; return iterator(s,e,i); })(0,userKeys.length,false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: userKeys.at(i) == valArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await userKeys.at(i)),(await valArr.at(i)))))}; + } + const saberforms = ({"1st": "shii-cho","2nd": "makashi","3rd": "soresu","4th": "ataru","5th": "shien","6th": "niman","7th": "juyo"}); + const saberformNames = Object.values(saberforms); + const nameArr = ["shii-cho", "makashi", "soresu", "ataru", "shien", "niman", "juyo"]; + {((cond) => {if (!cond) throw new Error("assertion failed: saberformNames.length == nameArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(saberformNames.length,nameArr.length)))}; + for (const i of ((s,e,i) => { function* iterator(start,end,inclusive) { let i = start; let limit = inclusive ? ((end < start) ? end - 1 : end + 1) : end; while (i < limit) yield i++; while (i > limit) yield i--; }; return iterator(s,e,i); })(0,saberformNames.length,false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: saberformNames.at(i) == nameArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await saberformNames.at(i)),(await nameArr.at(i)))))}; + } + } + } + return $Closure6; +} + +``` + +## inflight.$Closure7-1.js +```js +module.exports = function({ }) { + class $Closure7 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const lightsaberColorMap = ({"red": "sith","blue": "jedi"}); + const lightsaberColors = Object.keys(lightsaberColorMap); + const colorArr = ["red", "blue"]; + {((cond) => {if (!cond) throw new Error("assertion failed: lightsaberColors.length == colorArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(lightsaberColors.length,colorArr.length)))}; + for (const i of ((s,e,i) => { function* iterator(start,end,inclusive) { let i = start; let limit = inclusive ? ((end < start) ? end - 1 : end + 1) : end; while (i < limit) yield i++; while (i > limit) yield i--; }; return iterator(s,e,i); })(0,lightsaberColors.length,false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: lightsaberColors.at(i) == colorArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await lightsaberColors.at(i)),(await colorArr.at(i)))))}; + } + const isMandalorianWarrior = ({"bo katan": true,"jango": true,"satine": false,"boba": true}); + const mandalorianKeys = Object.keys(isMandalorianWarrior); + const keysArr = ["bo katan", "jango", "satine", "boba"]; + {((cond) => {if (!cond) throw new Error("assertion failed: mandalorianKeys.length == keysArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(mandalorianKeys.length,keysArr.length)))}; + for (const i of ((s,e,i) => { function* iterator(start,end,inclusive) { let i = start; let limit = inclusive ? ((end < start) ? end - 1 : end + 1) : end; while (i < limit) yield i++; while (i > limit) yield i--; }; return iterator(s,e,i); })(0,mandalorianKeys.length,false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: mandalorianKeys.at(i) == keysArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((await mandalorianKeys.at(i)),(await keysArr.at(i)))))}; + } + } + } + return $Closure7; +} + +``` + +## inflight.$Closure8-1.js +```js +module.exports = function({ }) { + class $Closure8 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const ruleOfTwo = ({"master": "apprentice"}); + const mutRuleOfTwo = {...(ruleOfTwo)}; + {((cond) => {if (!cond) throw new Error("assertion failed: mutRuleOfTwo.copy() == ruleOfTwo")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(({...(mutRuleOfTwo)}),ruleOfTwo)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mutRuleOfTwo.delete(\"master\") == true")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((delete (mutRuleOfTwo)["master"]),true)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mutRuleOfTwo.size() == 0")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(mutRuleOfTwo).length,0)))}; + } + } + return $Closure8; +} + +``` + +## inflight.$Closure9-1.js +```js +module.exports = function({ }) { + class $Closure9 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const authority = ({"republic": "senate","empire": "emperor"}); + const immutAuthority = ({...(authority)}); + {((cond) => {if (!cond) throw new Error("assertion failed: immutAuthority.copyMut() == authority")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })({...(immutAuthority)},authority)))}; + } + } + return $Closure9; +} + +``` + ## main.tf.json ```json { @@ -42,6 +328,318 @@ const std = $stdlib.std; class $Root extends $stdlib.std.Resource { constructor(scope, id) { super(scope, id); + class $Closure1 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure1-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType(this)}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure2 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure2-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure2Client = ${$Closure2._toInflightType(this)}; + const client = new $Closure2Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure3 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure3-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure3Client = ${$Closure3._toInflightType(this)}; + const client = new $Closure3Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure4 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure4-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure4Client = ${$Closure4._toInflightType(this)}; + const client = new $Closure4Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure5 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure5-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure5Client = ${$Closure5._toInflightType(this)}; + const client = new $Closure5Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure6 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure6-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure6Client = ${$Closure6._toInflightType(this)}; + const client = new $Closure6Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure7 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure7-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure7Client = ${$Closure7._toInflightType(this)}; + const client = new $Closure7Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure8 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure8-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure8Client = ${$Closure8._toInflightType(this)}; + const client = new $Closure8Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure9 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure9-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure9Client = ${$Closure9._toInflightType(this)}; + const client = new $Closure9Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure10 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure10-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure10Client = ${$Closure10._toInflightType(this)}; + const client = new $Closure10Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure11 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure11-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure11Client = ${$Closure11._toInflightType(this)}; + const client = new $Closure11Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure12 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure12-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure12Client = ${$Closure12._toInflightType(this)}; + const client = new $Closure12Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } const m = ({"hello": 123,"world": 99}); const mkeys = Object.keys(m); {((cond) => {if (!cond) throw new Error("assertion failed: mkeys.length == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(mkeys.length,2)))}; @@ -51,6 +649,100 @@ class $Root extends $stdlib.std.Resource { {((cond) => {if (!cond) throw new Error("assertion failed: mvalues.length == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(mvalues.length,2)))}; {((cond) => {if (!cond) throw new Error("assertion failed: mvalues.at(0) == 123")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((mvalues.at(0)),123)))}; {((cond) => {if (!cond) throw new Error("assertion failed: mvalues.at(1) == 99")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((mvalues.at(1)),99)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Map{} == MutMap{}")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(({}),({}))))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:equality",new $Closure1(this,"$Closure1")); + const apprentices = ({"plagueis": "sidious","dooku": "ventress"}); + (delete (apprentices)["plagueis"]); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.size() == 1")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(apprentices).length,1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.copy() == Map {\"dooku\" => \"ventress\"}")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(({...(apprentices)}),({"dooku": "ventress"}))))}; + ((obj, args) => { obj[args[0]] = args[1]; })(apprentices, ["sidious","dooku"]); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.get(\"sidious\") == \"dooku\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((apprentices)["sidious"],"dooku")))}; + ((obj, args) => { obj[args[0]] = args[1]; })(apprentices, ["sidious","maul"]); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices.get(\"sidious\") == \"maul\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((apprentices)["sidious"],"maul")))}; + ((map) => { for(const k in map){delete map[k]}; })(apprentices); + {((cond) => {if (!cond) throw new Error("assertion failed: apprentices == MutMap{}")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(apprentices,({}))))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:mutability",new $Closure2(this,"$Closure2")); + const trilogies = ({"PT": 2,"OT": 1,"ST": 3}); + {((cond) => {if (!cond) throw new Error("assertion failed: trilogies.size() == 3")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(trilogies).length,3)))}; + const mutTrilogies = ({"PT": 2,"OT": 1,"ST": 3}); + {((cond) => {if (!cond) throw new Error("assertion failed: mutTrilogies.size() == 3")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(mutTrilogies).length,3)))}; + (delete (mutTrilogies)["ST"]); + {((cond) => {if (!cond) throw new Error("assertion failed: mutTrilogies.size() == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(mutTrilogies).length,2)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:size()",new $Closure3(this,"$Closure3")); + const greeting = ({"hello": "there!"}); + {((cond) => {if (!cond) throw new Error("assertion failed: greeting.get(\"hello\") == \"there!\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((greeting)["hello"],"there!")))}; + const general = (greeting)["grievous"]; + {((cond) => {if (!cond) throw new Error("assertion failed: general == nil")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(general,undefined)))}; + const mutGreeting = ({"general": "kenobi"}); + {((cond) => {if (!cond) throw new Error("assertion failed: mutGreeting.get(\"general\") == \"kenobi\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((mutGreeting)["general"],"kenobi")))}; + const Viceroy = (mutGreeting)["gunray"]; + {((cond) => {if (!cond) throw new Error("assertion failed: Viceroy == nil")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Viceroy,undefined)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:get()",new $Closure4(this,"$Closure4")); + const legion501 = ({"fives": "CT-5555","rex": "CT-7567","appo": "CC-1119","jesse": "CT-5597"}); + {((cond) => {if (!cond) throw new Error("assertion failed: legion501.has(\"fives\") == true")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("fives" in (legion501)),true)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: legion501.has(\"rex\") == legion501.has(\"jesse\")")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("rex" in (legion501)),("jesse" in (legion501)))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: legion501.has(\"cody\") == false")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("cody" in (legion501)),false)))}; + const padawans = ({"ahsoka": "anakin","anakin": "kenobi","kenobi": "qui gon","qui gon": "dooku","dooku": "yoda"}); + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"anakin\") == true")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("anakin" in (padawans)),true)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"qui gon\") == padawans.has(\"dooku\") == padawans.has(\"anakin\")")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("qui gon" in (padawans)),("dooku" in (padawans)))),("anakin" in (padawans)))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"windu\") == padawans.has(\"sifo dyas\")")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("windu" in (padawans)),("sifo dyas" in (padawans)))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: padawans.has(\"revan\") == false")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(("revan" in (padawans)),false)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:has()",new $Closure5(this,"$Closure5")); + const forceUsers = ({"sith": ["malak", "vader", "bane"],"jedi": ["sunrider", "bastila", "bindo"]}); + const userKeys = Object.values(forceUsers); + const valArr = [["malak", "vader", "bane"], ["sunrider", "bastila", "bindo"]]; + {((cond) => {if (!cond) throw new Error("assertion failed: userKeys.length == valArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(userKeys.length,valArr.length)))}; + for (const i of $stdlib.std.Range.of(0, userKeys.length, false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: userKeys.at(i) == valArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((userKeys.at(i)),(valArr.at(i)))))}; + } + const saberforms = ({"1st": "shii-cho","2nd": "makashi","3rd": "soresu","4th": "ataru","5th": "shien","6th": "niman","7th": "juyo"}); + const saberformNames = Object.values(saberforms); + const nameArr = ["shii-cho", "makashi", "soresu", "ataru", "shien", "niman", "juyo"]; + {((cond) => {if (!cond) throw new Error("assertion failed: saberformNames.length == nameArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(saberformNames.length,nameArr.length)))}; + for (const i of $stdlib.std.Range.of(0, saberformNames.length, false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: saberformNames.at(i) == nameArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((saberformNames.at(i)),(nameArr.at(i)))))}; + } + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:values()",new $Closure6(this,"$Closure6")); + const lightsaberColorMap = ({"red": "sith","blue": "jedi"}); + const lightsaberColors = Object.keys(lightsaberColorMap); + const colorArr = ["red", "blue"]; + {((cond) => {if (!cond) throw new Error("assertion failed: lightsaberColors.length == colorArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(lightsaberColors.length,colorArr.length)))}; + for (const i of $stdlib.std.Range.of(0, lightsaberColors.length, false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: lightsaberColors.at(i) == colorArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((lightsaberColors.at(i)),(colorArr.at(i)))))}; + } + const isMandalorianWarrior = ({"bo katan": true,"jango": true,"satine": false,"boba": true}); + const mandalorianKeys = Object.keys(isMandalorianWarrior); + const keysArr = ["bo katan", "jango", "satine", "boba"]; + {((cond) => {if (!cond) throw new Error("assertion failed: mandalorianKeys.length == keysArr.length")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(mandalorianKeys.length,keysArr.length)))}; + for (const i of $stdlib.std.Range.of(0, mandalorianKeys.length, false)) { + {((cond) => {if (!cond) throw new Error("assertion failed: mandalorianKeys.at(i) == keysArr.at(i)")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((mandalorianKeys.at(i)),(keysArr.at(i)))))}; + } + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:keys()",new $Closure7(this,"$Closure7")); + const ruleOfTwo = ({"master": "apprentice"}); + const mutRuleOfTwo = {...(ruleOfTwo)}; + {((cond) => {if (!cond) throw new Error("assertion failed: mutRuleOfTwo.copy() == ruleOfTwo")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(({...(mutRuleOfTwo)}),ruleOfTwo)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mutRuleOfTwo.delete(\"master\") == true")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((delete (mutRuleOfTwo)["master"]),true)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mutRuleOfTwo.size() == 0")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(mutRuleOfTwo).length,0)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:copyMut()",new $Closure8(this,"$Closure8")); + const authority = ({"republic": "senate","empire": "emperor"}); + const immutAuthority = ({...(authority)}); + {((cond) => {if (!cond) throw new Error("assertion failed: immutAuthority.copyMut() == authority")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })({...(immutAuthority)},authority)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:copy()",new $Closure9(this,"$Closure9")); + const senate = ({"chancellor": "palpatine"}); + ((obj, args) => { obj[args[0]] = args[1]; })(senate, ["senator","organa"]); + {((cond) => {if (!cond) throw new Error("assertion failed: senate.get(\"senator\") == \"organa\"")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })((senate)["senator"],"organa")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: senate.size() == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(senate).length,2)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:set()",new $Closure10(this,"$Closure10")); + const position = ({"librarian": "jocasta"}); + ((map) => { for(const k in map){delete map[k]}; })(position); + {((cond) => {if (!cond) throw new Error("assertion failed: position.size() == 0")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(position).length,0)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:clear()",new $Closure11(this,"$Closure11")); + const sithTriumvirate = ({"traya": "lord of betrayal","nihilus": "lord of hunger","sion": "lord of pain"}); + (delete (sithTriumvirate)["nihilus"]); + {((cond) => {if (!cond) throw new Error("assertion failed: sithTriumvirate.size() == 2")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(Object.keys(sithTriumvirate).length,2)))}; + (delete (sithTriumvirate)["sion"]); + {((cond) => {if (!cond) throw new Error("assertion failed: sithTriumvirate == MutMap { \"traya\" => \"lord of betrayal\" }")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(sithTriumvirate,({"traya": "lord of betrayal"}))))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:delete()",new $Closure12(this,"$Closure12")); } } const $App = $stdlib.core.App.for(process.env.WING_TARGET); diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_test_sim.md index d18de1ca3bf..d67efd4a6ab 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.test.w_test_sim.md @@ -2,10 +2,21 @@ ## stdout.log ```log -pass ─ map.test.wsim (no tests) +pass ─ map.test.wsim » root/env0/test:equality +pass ─ map.test.wsim » root/env1/test:mutability +pass ─ map.test.wsim » root/env10/test:clear() +pass ─ map.test.wsim » root/env11/test:delete() +pass ─ map.test.wsim » root/env2/test:size() +pass ─ map.test.wsim » root/env3/test:get() +pass ─ map.test.wsim » root/env4/test:has() +pass ─ map.test.wsim » root/env5/test:values() +pass ─ map.test.wsim » root/env6/test:keys() +pass ─ map.test.wsim » root/env7/test:copyMut() +pass ─ map.test.wsim » root/env8/test:copy() +pass ─ map.test.wsim » root/env9/test:set() -Tests 1 passed (1) +Tests 12 passed (12) Test Files 1 passed (1) Duration ```