diff --git a/apps/wing/src/commands/pack.test.ts b/apps/wing/src/commands/pack.test.ts index d424bb258ba..6834f60ecf7 100644 --- a/apps/wing/src/commands/pack.test.ts +++ b/apps/wing/src/commands/pack.test.ts @@ -186,10 +186,18 @@ describe("wing pack", () => { await extractTarball(join(outdir, tarballPath), outdir); // symlink node_modules/@winglang/sdk to our version of the sdk so the import works - await fs.mkdir(join(outdir, "package", "node_modules", "@winglang"), { recursive: true }); + await fs.mkdir(join(outdir, "package", "node_modules", "@winglang", "sdk", "lib"), { + recursive: true, + }); + + await fs.symlink( + require.resolve("@winglang/sdk/lib/index.js"), + join(outdir, "package", "node_modules", "@winglang", "sdk", "index.js") + ); + await fs.symlink( - require.resolve("@winglang/sdk"), - join(outdir, "package", "node_modules", "@winglang", "sdk") + require.resolve("@winglang/sdk/lib/macros.js"), + join(outdir, "package", "node_modules", "@winglang", "sdk", "lib", "macros.js") ); const packagePath = join(outdir, "package"); diff --git a/docs/api/04-standard-library/std/string.md b/docs/api/04-standard-library/std/string.md index 63d7c79498e..54985c73ff8 100644 --- a/docs/api/04-standard-library/std/string.md +++ b/docs/api/04-standard-library/std/string.md @@ -22,7 +22,7 @@ String. | endsWith | Does this string end with the given searchString? | | indexOf | Returns the index of the first occurrence of searchString found. | | lowercase | Returns this string in lower case. | -| replace | Replaces the first occurence of a substring within a string. | +| replace | Replaces the first occurrence of a substring within a string. | | replaceAll | Replaces all occurrences of a substring within a string. | | split | Splits string by separator. | | startsWith | Does this string start with the given searchString? | @@ -126,7 +126,7 @@ Returns this string in lower case. replace(searchString: str, replaceString: str): str ``` -Replaces the first occurence of a substring within a string. +Replaces the first occurrence of a substring within a string. ###### `searchString`Required diff --git a/examples/tests/sdk_tests/function/aws-function.test.w b/examples/tests/sdk_tests/function/aws-function.test.w index 1da2ac9c8dd..c78b8d2a09a 100644 --- a/examples/tests/sdk_tests/function/aws-function.test.w +++ b/examples/tests/sdk_tests/function/aws-function.test.w @@ -37,7 +37,7 @@ let fn = new cloud.Function(inflight (msg: Json?) => { let fnInfo = getFunctionInfo(fn); -test "AWS Function" { +new std.Test(inflight () => { if let info = fnInfo { if target == "tf-aws" { assert(info.get("functionArn").contains("arn:aws:lambda:")); @@ -73,4 +73,4 @@ test "AWS Function" { msg = err; } expect.ok(msg.contains("fake error"), "Expected fake error message"); -} +}, timeout: 3m) as "AWS Function"; diff --git a/examples/tests/valid/chaining_macros.test.w b/examples/tests/valid/chaining_macros.test.w new file mode 100644 index 00000000000..ab4532616b5 --- /dev/null +++ b/examples/tests/valid/chaining_macros.test.w @@ -0,0 +1,91 @@ +bring expect; +bring math; + +struct Result { + item: Json?; + items: Array?; + mapItem: Map?; + mapItems: Array>?; + setItem: Set?; + setItems: Array>?; + structItem: Result?; + structItems: Array?; +} + +let result = Result {}; + +expect.equal(result.item?.tryGet("id"), nil); +expect.equal(result.item?.has("id"), nil); + +expect.equal(result.items?.tryAt(0)?.tryGet("id"), nil); +expect.equal(result.items?.tryAt(0)?.has("id"), nil); + +expect.equal(result.mapItem?.tryGet("a"), nil); +expect.equal(result.mapItem?.has("id"), nil); + +expect.equal(result.mapItems?.tryAt(0)?.tryGet("id"), nil); +expect.equal(result.mapItems?.tryAt(0)?.has("id"), nil); + +expect.equal(result.setItem?.size, nil); +expect.equal(result.setItem?.has(6), nil); + +expect.equal(result.setItems?.tryAt(0)?.size, nil); +expect.equal(result.setItems?.tryAt(0)?.has(6), nil); + +expect.equal(result.structItem?.item, nil); +expect.equal(result.structItems?.tryAt(0)?.item, nil); + +let var calls = 0; + +let makeArray = (): Array => { + calls = calls + 1; + return [1, 2, 3]; +}; + +expect.ok(makeArray()?.contains(2) ?? false); +expect.equal(calls, 1); + +test "optional chaining macros" { + let result = Result {}; + + expect.equal(result.item?.tryGet("id"), nil); + expect.equal(result.item?.has("id"), nil); + + expect.equal(result.items?.tryAt(0)?.tryGet("id"), nil); + expect.equal(result.items?.tryAt(0)?.has("id"), nil); + + expect.equal(result.mapItem?.tryGet("a"), nil); + expect.equal(result.mapItem?.has("id"), nil); + + expect.equal(result.mapItems?.tryAt(0)?.tryGet("id"), nil); + expect.equal(result.mapItems?.tryAt(0)?.has("id"), nil); + + expect.equal(result.setItem?.size, nil); + expect.equal(result.setItem?.has(6), nil); + + expect.equal(result.setItems?.tryAt(0)?.size, nil); + expect.equal(result.setItems?.tryAt(0)?.has(6), nil); + + expect.equal(result.structItem?.item, nil); + expect.equal(result.structItems?.tryAt(0)?.item, nil); + + let var calls = 0; + + let makeArray = (): Array => { + calls = calls + 1; + return [1, 2, 3]; + }; + + expect.ok(makeArray()?.contains(2) ?? false); + expect.equal(calls, 1); +} + + +test "nesting and chaining" { + let characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + let randomChar = characters.at(math.floor(math.random() * characters.length)); + // could not assert a real random in snapshot test so duplicated with fixed value + let fixedChar = characters.at(math.floor(0.67 * characters.length)); + expect.equal(fixedChar, "Y"); + +} diff --git a/libs/wingc/src/dtsify/snapshots/declarations.snap b/libs/wingc/src/dtsify/snapshots/declarations.snap index 59471505957..42e969f9733 100644 --- a/libs/wingc/src/dtsify/snapshots/declarations.snap +++ b/libs/wingc/src/dtsify/snapshots/declarations.snap @@ -49,6 +49,7 @@ pub class Child extends ParentClass impl ClassInterface {} ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $ParentClass }) { class Child extends $ParentClass { constructor({ }) { @@ -65,6 +66,7 @@ module.exports = function({ $ParentClass }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class InflightClass { async somethingFun() { @@ -80,6 +82,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $InflightClass }) { class ParentClass { constructor({ }) { @@ -102,6 +105,7 @@ module.exports = function({ $InflightClass }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -122,6 +126,7 @@ export * from "./preflight.lib-1.cjs" ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/libs/wingc/src/dtsify/snapshots/optionals.snap b/libs/wingc/src/dtsify/snapshots/optionals.snap index f2ec550c899..730d879f42c 100644 --- a/libs/wingc/src/dtsify/snapshots/optionals.snap +++ b/libs/wingc/src/dtsify/snapshots/optionals.snap @@ -28,6 +28,7 @@ pub class ParentClass impl ClassInterface { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class ParentClass { constructor({ }) { @@ -43,6 +44,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -63,6 +65,7 @@ export * from "./preflight.lib-1.cjs" ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 26bc2c65582..db75349a6fb 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -49,6 +49,7 @@ const ENV_WING_IS_TEST: &str = "$wing_is_test"; const OUTDIR_VAR: &str = "$outdir"; const PLATFORMS_VAR: &str = "$platforms"; const HELPERS_VAR: &str = "$helpers"; +const MACROS_VAR: &str = "$macros"; const EXTERN_VAR: &str = "$extern"; const ROOT_CLASS: &str = "$Root"; @@ -173,6 +174,7 @@ impl<'a> JSifier<'a> { output.line("\"use strict\";"); output.line(format!("const {STDLIB} = require('{STDLIB_MODULE}');")); + output.line(format!("const {MACROS_VAR} = require(\"@winglang/sdk/lib/macros\");")); if is_entrypoint { output.line(format!( @@ -890,6 +892,7 @@ impl<'a> JSifier<'a> { args_text_string = args_text_string[1..args_text_string.len() - 1].to_string(); } let args_text_string = escape_javascript_string(&args_text_string); + let mut is_optional = false; if let Some(function_sig) = function_sig { if let Some(js_override) = &function_sig.js_override { @@ -897,7 +900,12 @@ impl<'a> JSifier<'a> { CalleeKind::Expr(expr) => match &expr.kind { // for "loose" macros, e.g. `print()`, $self$ is the global object ExprKind::Reference(Reference::Identifier(_)) => "global".to_string(), - ExprKind::Reference(Reference::InstanceMember { object, .. }) => { + ExprKind::Reference(Reference::InstanceMember { + object, + optional_accessor, + .. + }) => { + is_optional = *optional_accessor; self.jsify_expression(&object, ctx).to_string() } ExprKind::Reference(Reference::TypeMember { property, .. }) => { @@ -915,10 +923,24 @@ impl<'a> JSifier<'a> { "this".to_string() } }; - let patterns = &[MACRO_REPLACE_SELF, MACRO_REPLACE_ARGS, MACRO_REPLACE_ARGS_TEXT]; - let replace_with = &[self_string, args_string, args_text_string]; - let ac = AhoCorasick::new(patterns).expect("Failed to create macro pattern"); - return new_code!(expr_span, ac.replace_all(js_override, replace_with)); + if function_sig.is_macro { + return new_code!( + expr_span, + format!( + "{}.{}({}, {}, {})", + MACROS_VAR, + js_override, + is_optional.to_string(), + self_string, + args_string + ) + ); + } else { + let patterns = &[MACRO_REPLACE_SELF, MACRO_REPLACE_ARGS, MACRO_REPLACE_ARGS_TEXT]; + let replace_with = &[self_string, args_string, args_text_string]; + let ac = AhoCorasick::new(patterns).expect("Failed to create macro pattern"); + return new_code!(expr_span, ac.replace_all(js_override, replace_with)); + } } // If this function requires an implicit scope argument, we need to add it to the args string @@ -2045,6 +2067,7 @@ impl<'a> JSifier<'a> { code.line("\"use strict\";"); code.line(format!("const {HELPERS_VAR} = require(\"@winglang/sdk/lib/helpers\");")); + code.line(format!("const {MACROS_VAR} = require(\"@winglang/sdk/lib/macros\");")); code.open(format!("module.exports = function({{ {inputs} }}) {{")); code.add_code(inflight_class_code); code.line(format!("return {name};")); diff --git a/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap b/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap index 6b9e961b445..cd9307171df 100644 --- a/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap +++ b/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x, $y }) { class $Closure1 { constructor({ }) { @@ -29,7 +30,7 @@ module.exports = function({ $x, $y }) { } async handle() { $helpers.assert($helpers.eq($x.length, 3), "x.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($y, 0), "hello"), "y.at(0) == \"hello\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $y, 0), "hello"), "y.at(0) == \"hello\""); } } return $Closure1; @@ -42,6 +43,7 @@ module.exports = function({ $x, $y }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap b/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap index d8f1b24ba2b..0470776be2c 100644 --- a/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap +++ b/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $s }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap b/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap index 64ff8536406..de08b194792 100644 --- a/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap +++ b/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s }) { class $Closure1 { constructor({ }) { @@ -26,7 +27,7 @@ module.exports = function({ $s }) { return $obj; } async handle() { - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })($s, "hello").length, 3), "s.get(\"hello\").length == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, $s, "hello").length, 3), "s.get(\"hello\").length == 3"); } } return $Closure1; @@ -39,6 +40,7 @@ module.exports = function({ $s }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap b/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap index 6d05b379a1c..ee35214307d 100644 --- a/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap +++ b/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class Bar extends $Foo { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $Foo }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Baz { constructor({ }) { @@ -53,6 +55,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -68,6 +71,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap b/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap index 679de1035dd..96ea059c512 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap @@ -26,6 +26,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class Base { constructor({ }) { @@ -44,6 +45,7 @@ module.exports = function({ $x }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ }) { @@ -63,6 +65,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap b/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap index 12a5ca772c0..eff98e98f52 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap @@ -26,6 +26,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ }) { @@ -41,6 +42,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ }) { @@ -57,6 +59,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap b/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap index e326397dd4b..3427e1fd0f9 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap @@ -32,6 +32,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ $this_b }) { @@ -52,6 +53,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ $this_b }) { @@ -71,6 +73,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap b/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap index b55ea996b25..5349789f367 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap @@ -31,6 +31,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ }) { @@ -49,6 +50,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ }) { @@ -72,6 +74,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap b/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap index 5704bd4528e..2b5f309b8c3 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap @@ -31,6 +31,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ }) { @@ -46,6 +47,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ }) { @@ -62,6 +64,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap index ac5a9a5dd34..7dae1fb4702 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ $this_b }) { @@ -62,6 +64,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap index 1f6f230ef6d..97d0763be7b 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ $this_f }) { @@ -62,6 +64,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/builtins.snap b/libs/wingc/src/jsify/snapshots/builtins.snap index e64c5167d9b..84e4b07fa49 100644 --- a/libs/wingc/src/jsify/snapshots/builtins.snap +++ b/libs/wingc/src/jsify/snapshots/builtins.snap @@ -16,6 +16,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -37,6 +38,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index 6dc3391bd36..ad34ba0e8b1 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -40,6 +41,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class B { static async bar() { @@ -56,6 +58,7 @@ module.exports = function({ $A }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap b/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap index 5ee52064c78..c28ff6d28ca 100644 --- a/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap index 04f67bc4675..5fca75ada33 100644 --- a/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap @@ -19,6 +19,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure1 { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ $foo }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap index b24b1a7bf4d..0e549fc0777 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -37,6 +38,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure2 { constructor({ }) { @@ -58,6 +60,7 @@ module.exports = function({ $foo }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap index 7995296f1f5..e0074c31adc 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure1 { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $x }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap index f8ca4d4acde..39f5191355d 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap @@ -21,6 +21,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure1 { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ $f }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -59,6 +61,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap index 7675b461039..17d630e32d8 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap @@ -26,6 +26,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f_b }) { class $Closure1 { constructor({ }) { @@ -47,6 +48,7 @@ module.exports = function({ $f_b }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -62,6 +64,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap index 25457cb6a6a..c89026882a7 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure1 { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $x }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap index 86dfdabf96d..8919763e214 100644 --- a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap +++ b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $util_Util, $x }) { class $Closure1 { constructor({ }) { @@ -43,6 +44,7 @@ module.exports = function({ $util_Util, $x }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap b/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap index 11ee4281c7d..b3eb23d845a 100644 --- a/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap +++ b/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket_this }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $bucket_this }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_token.snap b/libs/wingc/src/jsify/snapshots/capture_token.snap index 58e1a049759..b74028012e5 100644 --- a/libs/wingc/src/jsify/snapshots/capture_token.snap +++ b/libs/wingc/src/jsify/snapshots/capture_token.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url }) { class $Closure1 { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $api_url }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap index a6f06902a9e..1e6eb57e3ee 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -62,6 +63,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap index 9e3d965b248..fecdafe9039 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap @@ -21,6 +21,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -48,6 +49,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap index 969170e5651..8cbcbb7d562 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -40,6 +41,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index 03d379705ab..9d1c591dd48 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $Foo }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { } @@ -52,6 +54,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap index d4ac9c2a95e..59f90d98312 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -41,6 +42,7 @@ module.exports = function({ $Foo }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -59,6 +61,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index dd78f6ead2a..a8c9e909759 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -41,6 +42,7 @@ module.exports = function({ $Foo }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { static async bar() { @@ -57,6 +59,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap b/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap index 7708727f081..6d23e1107a5 100644 --- a/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap @@ -19,6 +19,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -45,6 +46,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index a598b9c2d49..b0f0159534c 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -19,6 +19,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class $Closure1 { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { } @@ -55,6 +57,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/closure_field.snap b/libs/wingc/src/jsify/snapshots/closure_field.snap index 63aa45da35d..bf67f27017f 100644 --- a/libs/wingc/src/jsify/snapshots/closure_field.snap +++ b/libs/wingc/src/jsify/snapshots/closure_field.snap @@ -37,6 +37,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $globalBucket }) { class $Closure1 { constructor({ }) { @@ -59,6 +60,7 @@ module.exports = function({ $globalBucket }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure2 { constructor({ }) { @@ -81,6 +83,7 @@ module.exports = function({ $x }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyResource { constructor({ $this_closure }) { @@ -100,6 +103,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/entrypoint_this.snap b/libs/wingc/src/jsify/snapshots/entrypoint_this.snap index 5e3fef89c82..c3f60f633ec 100644 --- a/libs/wingc/src/jsify/snapshots/entrypoint_this.snap +++ b/libs/wingc/src/jsify/snapshots/entrypoint_this.snap @@ -14,6 +14,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/enum_value.snap b/libs/wingc/src/jsify/snapshots/enum_value.snap index dcdb6cb1869..f6c2c177cc7 100644 --- a/libs/wingc/src/jsify/snapshots/enum_value.snap +++ b/libs/wingc/src/jsify/snapshots/enum_value.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyEnum, $x }) { class $Closure1 { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ $MyEnum, $x }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap b/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap index 22806d678b9..9977f9ee2b8 100644 --- a/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -50,6 +51,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap b/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap index 14da1b90b07..4025564dda4 100644 --- a/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -33,6 +34,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/func_returns_func.snap b/libs/wingc/src/jsify/snapshots/func_returns_func.snap index 8585f36233a..f97bc0672a3 100644 --- a/libs/wingc/src/jsify/snapshots/func_returns_func.snap +++ b/libs/wingc/src/jsify/snapshots/func_returns_func.snap @@ -21,6 +21,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -47,6 +48,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/identify_field.snap b/libs/wingc/src/jsify/snapshots/identify_field.snap index 24757c7d29e..70dd9ef1daf 100644 --- a/libs/wingc/src/jsify/snapshots/identify_field.snap +++ b/libs/wingc/src/jsify/snapshots/identify_field.snap @@ -23,6 +23,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ $this_bucket_this }) { @@ -42,6 +43,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap b/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap index db44928c5d9..7622fb95f67 100644 --- a/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap +++ b/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap @@ -35,6 +35,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ $this_c }) { @@ -60,6 +61,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/indirect_capture.snap b/libs/wingc/src/jsify/snapshots/indirect_capture.snap index 6d5fdfbdafd..c8a6859f763 100644 --- a/libs/wingc/src/jsify/snapshots/indirect_capture.snap +++ b/libs/wingc/src/jsify/snapshots/indirect_capture.snap @@ -33,6 +33,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure1 { constructor({ }) { @@ -54,6 +55,7 @@ module.exports = function({ $f }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class Capture { constructor({ }) { @@ -75,6 +77,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap index 5f3d58883e5..efc67282a7a 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -41,6 +42,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index e244cb71c3b..ae294904190 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -15,6 +15,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { } @@ -28,6 +29,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class B extends $A { } @@ -41,6 +43,7 @@ module.exports = function({ $A }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/inflight_constructor.snap b/libs/wingc/src/jsify/snapshots/inflight_constructor.snap index 7ad6bfcbbf7..c1b1c15be95 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_constructor.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_constructor.snap @@ -24,6 +24,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -45,6 +46,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/inflight_field.snap b/libs/wingc/src/jsify/snapshots/inflight_field.snap index 3b22cf584ea..507e34e9ff7 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field.snap @@ -23,6 +23,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -44,6 +45,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap index b25312bd7a5..d532fccfec8 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ }) { @@ -43,6 +44,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 77508eacc8f..b287add2a7f 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -21,6 +21,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { async getField() { @@ -42,6 +43,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap index d32585a30c7..b6331582417 100644 --- a/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_1_b }) { class $Closure1 { constructor({ }) { @@ -48,6 +49,7 @@ module.exports = function({ $__parent_this_1_b }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -63,6 +65,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/json_object.snap b/libs/wingc/src/jsify/snapshots/json_object.snap index c9547d625fc..56447e87ce2 100644 --- a/libs/wingc/src/jsify/snapshots/json_object.snap +++ b/libs/wingc/src/jsify/snapshots/json_object.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $jsonObj1, $std_Json }) { class $Closure1 { constructor({ }) { @@ -26,7 +27,7 @@ module.exports = function({ $jsonObj1, $std_Json }) { return $obj; } async handle() { - console.log(((json, opts) => { return JSON.stringify(json, null, opts?.indent) })($jsonObj1)); + console.log($macros.__Json_stringify(false, $std_Json, $jsonObj1)); } } return $Closure1; @@ -39,6 +40,7 @@ module.exports = function({ $jsonObj1, $std_Json }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap index 0ff4b510cc3..c80ab80ec28 100644 --- a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap +++ b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure1 { constructor({ }) { @@ -40,6 +41,7 @@ module.exports = function({ $x }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap index 393beb061ad..524e4aa4d96 100644 --- a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap +++ b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x, $y }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $x, $y }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap index 2a757e1b825..d9321b7da2d 100644 --- a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap +++ b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap @@ -24,6 +24,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ $_helpers_lookup_this_arr__0_ }) { @@ -43,6 +44,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap index 4bfa9779226..a932e302d25 100644 --- a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap +++ b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap @@ -19,6 +19,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $_helpers_lookup_a__0_ }) { class $Closure1 { constructor({ }) { @@ -40,6 +41,7 @@ module.exports = function({ $_helpers_lookup_a__0_ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap index 1dc9e36f082..2772548af5b 100644 --- a/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure2 { constructor({ }) { @@ -59,6 +61,7 @@ module.exports = function({ $f }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap b/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap index a2629aecf03..e9c061eb884 100644 --- a/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap +++ b/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap @@ -28,6 +28,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -49,6 +50,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -64,6 +66,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_self_reference.snap b/libs/wingc/src/jsify/snapshots/lift_self_reference.snap index 3665a7a2e6f..dec40ac1e4d 100644 --- a/libs/wingc/src/jsify/snapshots/lift_self_reference.snap +++ b/libs/wingc/src/jsify/snapshots/lift_self_reference.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -40,6 +41,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_string.snap b/libs/wingc/src/jsify/snapshots/lift_string.snap index 22f9a80ade2..3a9863a5a59 100644 --- a/libs/wingc/src/jsify/snapshots/lift_string.snap +++ b/libs/wingc/src/jsify/snapshots/lift_string.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_this.snap b/libs/wingc/src/jsify/snapshots/lift_this.snap index 347392d0f24..6c338371ad3 100644 --- a/libs/wingc/src/jsify/snapshots/lift_this.snap +++ b/libs/wingc/src/jsify/snapshots/lift_this.snap @@ -31,6 +31,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure1 { constructor({ }) { @@ -52,6 +53,7 @@ module.exports = function({ $f }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -76,6 +78,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap b/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap index f628c3f5fbd..31b0e039860 100644 --- a/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap +++ b/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ $foo_this_value }) { @@ -44,6 +45,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -59,6 +61,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_via_closure.snap b/libs/wingc/src/jsify/snapshots/lift_via_closure.snap index e9d202bfc6f..90547d131c5 100644 --- a/libs/wingc/src/jsify/snapshots/lift_via_closure.snap +++ b/libs/wingc/src/jsify/snapshots/lift_via_closure.snap @@ -24,6 +24,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket }) { class $Closure1 { constructor({ }) { @@ -45,6 +46,7 @@ module.exports = function({ $bucket }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn }) { class $Closure2 { constructor({ }) { @@ -66,6 +68,7 @@ module.exports = function({ $fn }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap b/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap index a0dd97b4d5a..8e80190119c 100644 --- a/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap +++ b/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap @@ -35,6 +35,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn }) { class $Closure1 { constructor({ }) { @@ -56,6 +57,7 @@ module.exports = function({ $fn }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyClosure { constructor({ $this_q }) { @@ -81,6 +83,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap index d50dbadf4fc..f4727147ab1 100644 --- a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $util_Util }) { class $Closure1 { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $util_Util }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap b/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap index c7c8e182c5a..fcb5634d0a2 100644 --- a/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap @@ -26,6 +26,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $y }) { class $Closure1 { constructor({ }) { @@ -47,6 +48,7 @@ module.exports = function({ $y }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class YourType { constructor({ }) { @@ -65,6 +67,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap b/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap index c9e36f7da14..46923228593 100644 --- a/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap @@ -32,6 +32,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $t_y_b }) { class $Closure1 { constructor({ }) { @@ -53,6 +54,7 @@ module.exports = function({ $t_y_b }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ }) { @@ -68,6 +70,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class YourType { constructor({ }) { @@ -83,6 +86,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index a1fec63f8b9..b7638237a47 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $Foo }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { } @@ -52,6 +54,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap b/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap index 6025edfaa1a..61f6630c8f3 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap @@ -19,6 +19,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -43,6 +44,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap index 4891ab25d11..541362370a3 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap @@ -19,6 +19,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -43,6 +44,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap index 8d691e6c0f8..6f091825f0e 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap b/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap index b2af859e3da..36d2293043d 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap @@ -24,6 +24,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -34,10 +35,10 @@ module.exports = function({ }) { async handle() { const arr = [0]; const i = 1; - arr.push(i); + $macros.__MutArray_push(false, arr, i); if (true) { const i = 2; - arr.push(i); + $macros.__MutArray_push(false, arr, i); } } } @@ -51,6 +52,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap b/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap index a32e57d771f..2c79c6cd01a 100644 --- a/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap +++ b/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap @@ -23,6 +23,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $i }) { class $Closure1 { constructor({ }) { @@ -32,10 +33,10 @@ module.exports = function({ $i }) { } async handle() { const arr = [0]; - arr.push($i); + $macros.__MutArray_push(false, arr, $i); if (true) { const i = 2; - arr.push(i); + $macros.__MutArray_push(false, arr, i); } } } @@ -49,6 +50,7 @@ module.exports = function({ $i }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap b/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap index 5c16f86b69a..d1103b28a75 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap @@ -15,6 +15,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ }) { @@ -30,6 +31,7 @@ module.exports = function({ }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ }) { @@ -46,6 +48,7 @@ module.exports = function({ $Base }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_collection.snap b/libs/wingc/src/jsify/snapshots/preflight_collection.snap index 8a3ce593fd1..3f15f644403 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_collection.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_collection.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $a }) { class $Closure1 { constructor({ }) { @@ -27,7 +28,7 @@ module.exports = function({ $a }) { } async handle() { $helpers.assert($helpers.eq($a.length, 2), "a.length == 2"); - console.log(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($a, 0)); + console.log($macros.__Array_at(false, $a, 0)); } } return $Closure1; @@ -40,6 +41,7 @@ module.exports = function({ $a }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap b/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap index 354be7bbec1..b97dcf7b82d 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $_helpers_lookup_arr__0_, $arr }) { class $Closure1 { constructor({ }) { @@ -44,6 +45,7 @@ module.exports = function({ $_helpers_lookup_arr__0_, $arr }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap b/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap index b58c9c64e41..8a4d93a5d9e 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap @@ -26,6 +26,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $a_bucky }) { class $Closure1 { constructor({ }) { @@ -47,6 +48,7 @@ module.exports = function({ $a_bucky }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -62,6 +64,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_object.snap b/libs/wingc/src/jsify/snapshots/preflight_object.snap index ec83d49ce92..99f5413c400 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $pf_obj }) { class $Closure1 { constructor({ }) { @@ -44,6 +45,7 @@ module.exports = function({ $pf_obj }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -63,6 +65,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap b/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap index 3652c73a9d8..5af22f7d172 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $t_b }) { class $Closure1 { constructor({ }) { @@ -48,6 +49,7 @@ module.exports = function({ $t_b }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ }) { @@ -63,6 +65,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap index faa33f646fa..e6e26779170 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap @@ -19,6 +19,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -41,6 +42,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap index 30107b4ba44..6c638a57e3c 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap @@ -25,6 +25,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class Foo { constructor({ }) { @@ -46,6 +47,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/preflight_value_field.snap b/libs/wingc/src/jsify/snapshots/preflight_value_field.snap index fe84ed16767..3171da50ba8 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_value_field.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_value_field.snap @@ -30,6 +30,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $t_last, $t_name }) { class $Closure1 { constructor({ }) { @@ -53,6 +54,7 @@ module.exports = function({ $t_last, $t_name }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ }) { @@ -68,6 +70,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap index 9c02468743f..6d722075bf4 100644 --- a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -28,6 +28,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $InflightC }) { class $Closure1 { constructor({ }) { @@ -50,6 +51,7 @@ module.exports = function({ $InflightC }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $pc }) { class InflightC { async foo() { @@ -66,6 +68,7 @@ module.exports = function({ $pc }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class PreflightC { constructor({ }) { @@ -83,6 +86,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/read_primitive_value.snap b/libs/wingc/src/jsify/snapshots/read_primitive_value.snap index 71846fa5fa3..a3da9938d00 100644 --- a/libs/wingc/src/jsify/snapshots/read_primitive_value.snap +++ b/libs/wingc/src/jsify/snapshots/read_primitive_value.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $x }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap b/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap index ef95b41efd4..565a41ea341 100644 --- a/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap +++ b/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -48,6 +49,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap b/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap index 9f171bb8342..9ede102b2d4 100644 --- a/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/ref_std_macro.snap b/libs/wingc/src/jsify/snapshots/ref_std_macro.snap index 29dcd36e088..f053244e227 100644 --- a/libs/wingc/src/jsify/snapshots/ref_std_macro.snap +++ b/libs/wingc/src/jsify/snapshots/ref_std_macro.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $arr }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $arr }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap index 83cb0cec392..902e1e792b9 100644 --- a/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s }) { class MyType { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $s }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap index a888c773f87..a08624104c9 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -41,6 +42,7 @@ module.exports = function({ $Foo }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { static async a() { @@ -57,6 +59,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap index 8d074bb6294..fc1875cfc7b 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap @@ -24,6 +24,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -45,6 +46,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index 16c0a3330aa..93a1ed13e1e 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -32,6 +32,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -53,6 +54,7 @@ module.exports = function({ $Foo }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s }) { class Foo { async foofoo1() { @@ -69,6 +71,7 @@ module.exports = function({ $s }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap b/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap index 5662232fe0e..22fa3dbaaad 100644 --- a/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap +++ b/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap @@ -18,6 +18,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $a }) { class $Closure1 { constructor({ }) { @@ -39,6 +40,7 @@ module.exports = function({ $a }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap index e9a742dd91d..27543433cd0 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap @@ -24,6 +24,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ $this_x }) { @@ -43,6 +44,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap index f2024f81144..074c341b1f3 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap @@ -24,13 +24,14 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ $this_arr }) { this.$this_arr = $this_arr; } async method() { - ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(this.$this_arr, 1); + $macros.__Array_at(false, this.$this_arr, 1); } } return Foo; @@ -43,6 +44,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap index 091a6c56305..619b893ea82 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap @@ -34,6 +34,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ $this_b, $this_s }) { @@ -59,6 +60,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap index 59de0ab833f..a3e9a671dc8 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class Foo { constructor({ $this_name }) { @@ -46,6 +47,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap index 0bfee22ecd0..946025da289 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap @@ -22,6 +22,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $q }) { class MyType { constructor({ }) { @@ -40,6 +41,7 @@ module.exports = function({ $q }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap index 556a591b173..69282ce31f2 100644 --- a/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyType }) { class $Closure1 { constructor({ }) { @@ -41,6 +42,7 @@ module.exports = function({ $MyType }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ }) { @@ -59,6 +61,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap b/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap index 41223b79652..b65299cd215 100644 --- a/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyType }) { class $Closure1 { constructor({ }) { @@ -48,6 +49,7 @@ module.exports = function({ $MyType }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class MyType { constructor({ }) { @@ -67,6 +69,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index 7927cad2ac6..ccbd6c5cfc3 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -26,6 +26,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class $Closure1 { constructor({ }) { @@ -52,6 +53,7 @@ module.exports = function({ $A }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { static async foo() { @@ -68,6 +70,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap index 47b6e8d1b54..482bea86098 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap @@ -24,6 +24,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class $Closure1 { constructor({ }) { @@ -49,6 +50,7 @@ module.exports = function({ $A }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -67,6 +69,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap b/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap index 0fb70208cdc..1d2d14e324f 100644 --- a/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap @@ -25,6 +25,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class $Closure1 { constructor({ }) { @@ -46,6 +47,7 @@ module.exports = function({ $A }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class A { constructor({ }) { @@ -64,6 +66,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap index c3f8f6cf967..dfb01ffbfc0 100644 --- a/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap @@ -26,6 +26,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -59,6 +60,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap index 6f543ce5dca..6129f21524c 100644 --- a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap +++ b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap @@ -17,6 +17,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $std_Json, $std_String }) { class $Closure1 { constructor({ }) { @@ -26,7 +27,7 @@ module.exports = function({ $std_Json, $std_String }) { } async handle() { console.log((await $std_String.fromJson("hello"))); - $helpers.assert($helpers.eq(Object.values(({})).length, 0), "Json.values(Json {}).length == 0"); + $helpers.assert($helpers.eq($macros.__Json_values(false, $std_Json, ({})).length, 0), "Json.values(Json {}).length == 0"); } } return $Closure1; @@ -39,6 +40,7 @@ module.exports = function({ $std_Json, $std_String }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference.snap b/libs/wingc/src/jsify/snapshots/transitive_reference.snap index f8c50f0ed43..1f3ce63b815 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference.snap @@ -37,6 +37,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $t }) { class $Closure1 { constructor({ }) { @@ -58,6 +59,7 @@ module.exports = function({ $t }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ $this_b }) { @@ -82,6 +84,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index 1849024381c..fd882750322 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -27,6 +27,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyInflightClass }) { class $Closure1 { constructor({ }) { @@ -49,6 +50,7 @@ module.exports = function({ $MyInflightClass }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class MyInflightClass { async putInBucket() { @@ -65,6 +67,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap index 3042973f08b..a8ffbcf48b4 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap @@ -33,6 +33,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $t }) { class $Closure1 { constructor({ }) { @@ -54,6 +55,7 @@ module.exports = function({ $t }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class MyType { constructor({ }) { @@ -72,6 +74,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyType }) { class YourType { constructor({ }) { @@ -90,6 +93,7 @@ module.exports = function({ $MyType }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap b/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap index 3a4369be705..c62d0539db6 100644 --- a/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap +++ b/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap @@ -23,6 +23,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -47,6 +48,7 @@ module.exports = function({ $b }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/use_util_functions.snap b/libs/wingc/src/jsify/snapshots/use_util_functions.snap index 0b505ac7ea0..5487cc2850d 100644 --- a/libs/wingc/src/jsify/snapshots/use_util_functions.snap +++ b/libs/wingc/src/jsify/snapshots/use_util_functions.snap @@ -16,6 +16,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $util_Util }) { class $Closure1 { constructor({ }) { @@ -37,6 +38,7 @@ module.exports = function({ $util_Util }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap b/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap index d2b6386c344..ac3cba313a0 100644 --- a/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap @@ -23,6 +23,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyType { constructor({ }) { @@ -45,6 +46,7 @@ module.exports = function({ }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/jsify/snapshots/wait_util.snap b/libs/wingc/src/jsify/snapshots/wait_util.snap index 97d0ded8e08..4e2611006de 100644 --- a/libs/wingc/src/jsify/snapshots/wait_util.snap +++ b/libs/wingc/src/jsify/snapshots/wait_util.snap @@ -20,6 +20,7 @@ source: libs/wingc/src/jsify/tests.rs ```js "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $util_Util }) { class $Closure1 { constructor({ }) { @@ -44,6 +45,7 @@ module.exports = function({ $util_Util }) { ```js "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/libs/wingc/src/lsp/snapshots/completions/partial_reference_call.snap b/libs/wingc/src/lsp/snapshots/completions/partial_reference_call.snap index 0414cb6b862..7ba48bf76bb 100644 --- a/libs/wingc/src/lsp/snapshots/completions/partial_reference_call.snap +++ b/libs/wingc/src/lsp/snapshots/completions/partial_reference_call.snap @@ -81,7 +81,7 @@ source: libs/wingc/src/lsp/completions.rs detail: "(searchString: str, replaceString: str): str" documentation: kind: markdown - value: "Replaces the first occurence of a substring within a string.\n\n#### Returns\nThe modified string after replacement." + value: "Replaces the first occurrence of a substring within a string.\n\n#### Returns\nThe modified string after replacement." sortText: ff|replace insertText: replace($1) insertTextFormat: 2 diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 66d0e30fa5d..6ebbb142a02 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -800,7 +800,9 @@ pub struct FunctionSignature { /// - `$self$`: The expression on which this function was called /// - `$args$`: the arguments passed to this function call /// - `$args_text$`: the original source text of the arguments passed to this function call, escaped + /// Those functions will be compiled into a separate file and retrieved when creating and running the js output. pub js_override: Option, + pub is_macro: bool, pub docs: Docs, } @@ -2036,6 +2038,7 @@ impl<'a> TypeChecker<'a> { return_type: self.types.void(), phase: Phase::Independent, js_override: Some("console.log($args$)".to_string()), + is_macro: false, docs: Docs::with_summary("Logs a value"), implicit_scope_param: false, }), @@ -2062,6 +2065,7 @@ impl<'a> TypeChecker<'a> { return_type: self.types.void(), phase: Phase::Independent, js_override: Some("$helpers.assert($args$, \"$args_text$\")".to_string()), + is_macro: false, docs: Docs::with_summary("Asserts that a condition is true"), implicit_scope_param: false, }), @@ -2080,6 +2084,7 @@ impl<'a> TypeChecker<'a> { return_type: self.types.anything(), phase: Phase::Independent, js_override: Some("$args$".to_string()), + is_macro: false, docs: Docs::with_summary("Casts a value into a different type. This is unsafe and can cause runtime errors"), implicit_scope_param: false, }), @@ -2108,6 +2113,7 @@ impl<'a> TypeChecker<'a> { return_type: std_node, phase: Phase::Preflight, js_override: Some("$helpers.nodeof($args$)".to_string()), + is_macro: false, docs: Docs::with_summary("Obtain the tree node of a preflight resource."), implicit_scope_param: false, }), @@ -2163,6 +2169,7 @@ It should primarily be used in preflight or in inflights that are guaranteed to phase: Phase::Preflight, // The emitted JS is dynamic js_override: None, + is_macro: false, docs: Docs::with_summary( r#"Create an inflight function from the given file. The file must be a JavaScript or TypeScript file with a default export that matches the inferred return where `@inflight` is used. @@ -4080,6 +4087,7 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); return_type: self.resolve_type_annotation(ast_sig.return_type.as_ref(), env), phase: ast_sig.phase, js_override: None, + is_macro: false, docs: Docs::default(), implicit_scope_param: false, }; @@ -5892,6 +5900,7 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); return_type: new_return_type, phase: if new_this_type.is_none() { env.phase } else { sig.phase }, js_override: sig.js_override.clone(), + is_macro: sig.is_macro, docs: sig.docs.clone(), implicit_scope_param: sig.implicit_scope_param, }; @@ -7195,6 +7204,7 @@ mod tests { return_type: ret, phase, js_override: None, + is_macro: false, docs: Docs::default(), implicit_scope_param: false, }) diff --git a/libs/wingc/src/type_check/jsii_importer.rs b/libs/wingc/src/type_check/jsii_importer.rs index de39f947dff..9ad3c1ee0db 100644 --- a/libs/wingc/src/type_check/jsii_importer.rs +++ b/libs/wingc/src/type_check/jsii_importer.rs @@ -306,13 +306,22 @@ impl<'a> JsiiImporter<'a> { }) .unwrap_or_default(); + let is_macro = extract_docstring_tag(&first_method.docs, "macro") + .map(|s| s.to_string()) + .is_some(); + let wing_type = self.wing_types.add_type(Type::Function(FunctionSignature { docs: Docs::from(&jsii_interface.docs), this_type: None, parameters, return_type, phase, - js_override: extract_docstring_tag(&first_method.docs, "macro").map(|s| s.to_string()), + js_override: if is_macro { + Some(format!("__{}_{}", &type_name, &first_method.name)) + } else { + None + }, + is_macro, implicit_scope_param: false, })); @@ -542,6 +551,9 @@ impl<'a> JsiiImporter<'a> { }); } } + + let is_macro = extract_docstring_tag(&m.docs, "macro").map(|s| s.to_string()).is_some(); + let this_type = if is_static { None } else { Some(wing_type) }; let method_sig = self.wing_types.add_type(Type::Function(FunctionSignature { docs: Docs::from(&m.docs), @@ -549,7 +561,12 @@ impl<'a> JsiiImporter<'a> { parameters: fn_params, return_type, phase: member_phase, - js_override: extract_docstring_tag(&m.docs, "macro").map(|s| s.to_string()), + js_override: if is_macro { + Some(format!("__{}_{}", &wing_type, &m.name)) + } else { + None + }, + is_macro, implicit_scope_param: false, })); let sym = Self::jsii_name_to_symbol(&m.name, &m.location_in_module); @@ -809,6 +826,7 @@ impl<'a> JsiiImporter<'a> { return_type: new_type, phase: member_phase, js_override: None, + is_macro: false, docs: Docs::from(&initializer.docs), implicit_scope_param: false, })); diff --git a/libs/wingsdk/.projen/deps.json b/libs/wingsdk/.projen/deps.json index 54310bbd52c..5ac5b41cc7a 100644 --- a/libs/wingsdk/.projen/deps.json +++ b/libs/wingsdk/.projen/deps.json @@ -144,6 +144,11 @@ "version": "^9", "type": "build" }, + { + "name": "ts-morph", + "version": "^23.0.0", + "type": "build" + }, { "name": "tsx", "type": "build" diff --git a/libs/wingsdk/.projen/tasks.json b/libs/wingsdk/.projen/tasks.json index 7980134af10..bf1ca29a47d 100644 --- a/libs/wingsdk/.projen/tasks.json +++ b/libs/wingsdk/.projen/tasks.json @@ -102,6 +102,9 @@ "name": "compile", "description": "Only compile", "steps": [ + { + "spawn": "generate-macros" + }, { "exec": "jsii --silence-warnings=reserved-word" } @@ -146,6 +149,14 @@ } ] }, + "generate-macros": { + "name": "generate-macros", + "steps": [ + { + "exec": "tsx scripts/generate-macros.mts" + } + ] + }, "install": { "name": "install", "description": "Install project dependencies and update lockfile (non-frozen)", diff --git a/libs/wingsdk/.projenrc.ts b/libs/wingsdk/.projenrc.ts index b23ffbd0d30..a21ccd3f599 100644 --- a/libs/wingsdk/.projenrc.ts +++ b/libs/wingsdk/.projenrc.ts @@ -118,6 +118,7 @@ const project = new cdk.JsiiProject({ "nanoid", // for ESM import test in target-sim/function.test.ts "chalk", "tsx", + "ts-morph@^23.0.0", ...JSII_DEPS, ], eslintOptions: { @@ -296,6 +297,13 @@ project.tasks .tryFind("unbump")! .reset("pnpm version 0.0.0 --allow-same-version"); +// --------------- macros ----------------- + +const macros = project.addTask("generate-macros", { + exec: "tsx scripts/generate-macros.mts", +}); +project.compileTask.prependSpawn(macros); + // --------------- docs ----------------- const docgen = project.tasks.tryFind("docgen")!; diff --git a/libs/wingsdk/package.json b/libs/wingsdk/package.json index 42a1dbb0a35..651b8c9ddd9 100644 --- a/libs/wingsdk/package.json +++ b/libs/wingsdk/package.json @@ -17,6 +17,7 @@ "docgen": "pnpm exec projen docgen", "eject": "pnpm exec projen eject", "eslint": "pnpm exec projen eslint", + "generate-macros": "pnpm exec projen generate-macros", "package": "pnpm exec projen package", "package-all": "pnpm exec projen package-all", "package:js": "pnpm exec projen package:js", @@ -68,6 +69,7 @@ "prettier": "^2.8.8", "projen": "^0.71.163", "standard-version": "^9", + "ts-morph": "^23.0.0", "tsx": "^4.15.7", "typescript": "^5.5.2", "vitest": "^1.6.0", diff --git a/libs/wingsdk/scripts/generate-macros.mts b/libs/wingsdk/scripts/generate-macros.mts new file mode 100644 index 00000000000..64d46933c1d --- /dev/null +++ b/libs/wingsdk/scripts/generate-macros.mts @@ -0,0 +1,45 @@ +import { MethodDeclaration, Project, SyntaxKind } from "ts-morph"; + +const MACRO = "macro"; + +const project = new Project(); + +const sourceFiles = project.addSourceFilesAtPaths("src/std/*.ts"); + +function extractJSDocs(node: MethodDeclaration) { + const jsDocs = node.getChildrenOfKind(SyntaxKind.JSDoc); + if (!jsDocs || !jsDocs.length) { + return undefined; + } + return jsDocs[0] + .getTags() + .find((d) => d.getTagName() === MACRO) + ?.getComment(); +} + +let macroFileContent = ` +// This file is generated by the generate-macro npm script. Changes will be overridden. +`; + +for (const file of sourceFiles) { + for (const cls of file.getClasses()) { + for (const mtd of cls.getMethods()) { + const macro = extractJSDocs(mtd); + if (macro) { + const spreadArgs = macro.includes("...$args$") ? "..." : ""; + macroFileContent += ` + exports.__${cls.getName()}_${mtd.getName()} = (skipIfNil, $self$, ${spreadArgs}$args$) => { + if (skipIfNil && $self$ === undefined) return $self$; + return ${macro} + } + `; + } + } + } +} + +project.createSourceFile("lib/macros.js", macroFileContent, { + overwrite: true, +}); + +await project.save(); diff --git a/libs/wingsdk/src/shared-gcp/function.inflight.ts b/libs/wingsdk/src/shared-gcp/function.inflight.ts index e53c4f5bc7f..d2655f0cef1 100644 --- a/libs/wingsdk/src/shared-gcp/function.inflight.ts +++ b/libs/wingsdk/src/shared-gcp/function.inflight.ts @@ -65,7 +65,8 @@ export class FunctionClient implements IFunctionClient { }, }, }); - return (res.data as Json | undefined) ?? undefined; + /// The gcp call returns "" even for an undefined call + return (res.data as undefined | Json) || undefined; } catch (error) { throw new Error( `Error while invoking the function ${this.functionName}:\n${ diff --git a/libs/wingsdk/src/std/array.ts b/libs/wingsdk/src/std/array.ts index c65097dee4f..2255e1e2770 100644 --- a/libs/wingsdk/src/std/array.ts +++ b/libs/wingsdk/src/std/array.ts @@ -129,7 +129,7 @@ export class Array { /** * Returns a shallow copy of a portion of the array. * - * @macro $self$.slice($args$) + * @macro $self$.slice(...$args$) * * @param start the beginning index of the slice, inclusive. * @param end the ending index of the slice, exclusive. @@ -253,7 +253,7 @@ export class MutArray { /** * Add values to end of array * - * @macro $self$.push($args$) + * @macro $self$.push(...$args$) * * @param values values to add */ @@ -273,7 +273,7 @@ export class MutArray { /** * Removes value from the given index of an array * - * @macro ((obj, args) => { if (args[0] < 0 || args[0] >= $self$.length) throw new Error("Index out of bounds"); return obj.splice(args[0], 1)[0]; })($self$, [$args$]) + * @macro ((obj, index) => { if (index < 0 || index >= $self$.length) throw new Error("Index out of bounds"); return obj.splice(index, 1)[0]; })($self$, $args$) * * @param index the index to remove the value at * @returns the value removed @@ -287,7 +287,7 @@ export class MutArray { /** * Sets a new value at the given index of an array * - * @macro ((obj, args) => { if (args[0] < 0 || args[0] >= $self$.length) throw new Error("Index out of bounds"); obj[args[0]] = args[1]; })($self$, [$args$]) + * @macro ((obj, index, value) => { if (index < 0 || index >= $self$.length) throw new Error("Index out of bounds"); obj[index] = value; })($self$, ...$args$) * * @param index the index to set the value at * @param value the value to set at the given index @@ -302,7 +302,7 @@ export class MutArray { /** * Inserts a new value at the given index of an array * - * @macro ((obj, args) => { if (args[0] < 0 || args[0] > $self$.length) throw new Error("Index out of bounds"); obj.splice(args[0], 0, args[1]); })($self$, [$args$]) + * @macro ((obj, index, value) => { if (index < 0 || index > $self$.length) throw new Error("Index out of bounds"); obj.splice(index, 0, value); })($self$, ...$args$) * * @param index the index to insert the value at * @param value the value to insert at the given index @@ -317,7 +317,7 @@ export class MutArray { /** * Removes first occurrence of a given value in an array * - * @macro ((obj, args) => { if (obj.indexOf(args[0]) !== -1) { obj.splice(obj.indexOf(args[0]), 1); return true; } return false; })($self$, [$args$]) + * @macro ((obj, index) => { if (obj.indexOf(index) !== -1) { obj.splice(obj.indexOf(index), 1); return true; } return false; })($self$, $args$) * * @param value the value to remove * @returns true if value was removed @@ -330,7 +330,7 @@ export class MutArray { /** * Returns a shallow copy of a portion of the array. * - * @macro $self$.slice($args$) + * @macro $self$.slice(...$args$) * * @param start the beginning index of the slice, inclusive. * @param end the ending index of the slice, exclusive. diff --git a/libs/wingsdk/src/std/json.ts b/libs/wingsdk/src/std/json.ts index eb34eca74ef..7631fbb765f 100644 --- a/libs/wingsdk/src/std/json.ts +++ b/libs/wingsdk/src/std/json.ts @@ -84,7 +84,7 @@ export class Json { /** * Deletes a key in a given Json * - * @macro ((json, key) => { delete json[key]; })($args$) + * @macro ((json, key) => { delete json[key]; })(...$args$) * * @param json to delete key from * @param key the key to delete @@ -98,7 +98,7 @@ export class Json { /** * Formats Json as string * - * @macro ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })($args$) + * @macro ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(...$args$) * * @param json to format as string * @returns string representation of the Json @@ -342,7 +342,7 @@ export class MutJson { /** * Adds or updates an element in MutJson with a specific key and value * - * @macro ((obj, key, value) => { obj[key] = value; })($self$, $args$) + * @macro ((obj, key, value) => { obj[key] = value; })($self$, ...$args$) * * @param key The key of the element to add * @param value The value of the element to add @@ -356,7 +356,7 @@ export class MutJson { /** * Set element in MutJson Array with a specific key and value * - * @macro ((obj, idx, value) => { obj[idx] = value; })($self$, $args$) + * @macro ((obj, idx, value) => { obj[idx] = value; })($self$, ...$args$) * * @param value The value of the element to set */ @@ -475,7 +475,7 @@ export class MutJson { /** * Checks if a Json object has a given key * - * @macro ((obj, key) => { return obj.hasOwnProperty(key); })($self$,$args$) + * @macro ((obj, key) => { return obj?.hasOwnProperty(key); })($self$,$args$) * * @param key The key to check * @returns Boolean value corresponding to whether the key exists diff --git a/libs/wingsdk/src/std/map.ts b/libs/wingsdk/src/std/map.ts index 956d2f71c90..355a9588383 100644 --- a/libs/wingsdk/src/std/map.ts +++ b/libs/wingsdk/src/std/map.ts @@ -64,7 +64,7 @@ export class Map { /** * Optionally returns a specified element from the map. * - * @macro ($self$)[$args$] + * @macro ($self$)?.[$args$] * * @param key The key of the element to return. * @returns The element associated with the specified key, or undefined if the key can't be found @@ -211,7 +211,7 @@ export class MutMap { /** * Optionally returns a specified element from the map. * - * @macro ($self$)[$args$] + * @macro ($self$)?.[$args$] * * @param key The key of the element to return. * @returns The element associated with the specified key, or undefined if the key can't be found @@ -238,7 +238,7 @@ export class MutMap { * Adds or updates an entry in a Map object with a specified key and a value. * * TODO: revisit this macro after we support indexed args https://github.com/winglang/wing/issues/1659 - * @macro ((obj, args) => { obj[args[0]] = args[1]; })($self$, [$args$]) + * @macro ((obj, key, value) => { obj[key] = value; })($self$, ...$args$) * * @param key The key of the element to add * @param value The value of the element to add diff --git a/libs/wingsdk/src/std/string.ts b/libs/wingsdk/src/std/string.ts index 82cff5cfe1e..c0492665767 100644 --- a/libs/wingsdk/src/std/string.ts +++ b/libs/wingsdk/src/std/string.ts @@ -154,9 +154,9 @@ export class String { } /** - * Replaces the first occurence of a substring within a string. + * Replaces the first occurrence of a substring within a string. * - * @macro $self$.replace($args$) + * @macro $self$.replace(...$args$) * * @param searchString The substring to search for. * @param replaceString The replacement substring. @@ -165,13 +165,13 @@ export class String { public replace(searchString: string, replaceString: string): string { searchString; replaceString; - throw new Error("Abstract"); + throw new Error("Macro"); } /** * Replaces all occurrences of a substring within a string. * - * @macro $self$.replaceAll($args$) + * @macro $self$.replaceAll(...$args$) * * @param searchString The substring to search for. * @param replaceString The replacement substring. diff --git a/libs/wingsdk/src/std/struct.ts b/libs/wingsdk/src/std/struct.ts index 532cb2b9a83..0fc41ee8ae7 100644 --- a/libs/wingsdk/src/std/struct.ts +++ b/libs/wingsdk/src/std/struct.ts @@ -19,7 +19,7 @@ export class Struct { /** * Converts a Json to a Struct * - * @macro $self$._fromJson($args$) + * @macro $self$._fromJson(...$args$) */ public static fromJson(json: Json, options?: JsonValidationOptions): T1 { json; @@ -30,7 +30,7 @@ export class Struct { /** * Converts a Json to a Struct, returning nil if the Json is not valid * - * @macro $self$._tryFromJson($args$) + * @macro $self$._tryFromJson(...$args$) */ public static tryFromJson(json: Json): T1 | undefined { json; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 338f1199e5e..f62c476864a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1514,6 +1514,9 @@ importers: standard-version: specifier: ^9 version: 9.5.0 + ts-morph: + specifier: ^23.0.0 + version: 23.0.0 tsx: specifier: ^4.15.7 version: 4.15.7 @@ -10475,6 +10478,15 @@ packages: /@trpc/server@10.45.2: resolution: {integrity: sha512-wOrSThNNE4HUnuhJG6PfDRp4L2009KDVxsd+2VYH8ro6o/7/jwYZ8Uu5j+VaW+mOmc8EHerHzGcdbGNQSAUPgg==} + /@ts-morph/common@0.24.0: + resolution: {integrity: sha512-c1xMmNHWpNselmpIqursHeOHHBTIsJLbB+NuovbTTRCNiTLEr/U9dbJ8qy0jd/O2x5pc3seWuOUN5R2IoOTp8A==} + dependencies: + fast-glob: 3.3.2 + minimatch: 9.0.4 + mkdirp: 3.0.1 + path-browserify: 1.0.1 + dev: true + /@tufjs/canonical-json@2.0.0: resolution: {integrity: sha512-yVtV8zsdo8qFHe+/3kw81dSLyF7D576A5cCFCi4X7B39tWT7SekaEFUnvnWJHz+9qO7qJTah1JbrDjWKqFtdWA==} engines: {node: ^16.14.0 || >=18.0.0} @@ -13333,6 +13345,10 @@ packages: engines: {node: '>=16'} dev: true + /code-block-writer@13.0.1: + resolution: {integrity: sha512-c5or4P6erEA69TxaxTNcHUNcIn+oyxSRTOWV+pSYF+z4epXqNvwvJ70XPGjPNgue83oAFAPBRQYwpAJ/Hpe/Sg==} + dev: true + /code-excerpt@3.0.0: resolution: {integrity: sha512-VHNTVhd7KsLGOqfX3SyeO8RyYPMp1GJOg194VITk04WMYCv4plV68YWe6TJZxd9MhobjtpMRnVky01gqZsalaw==} engines: {node: '>=10'} @@ -18755,6 +18771,12 @@ packages: engines: {node: '>=10'} hasBin: true + /mkdirp@3.0.1: + resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==} + engines: {node: '>=10'} + hasBin: true + dev: true + /mlly@1.7.1: resolution: {integrity: sha512-rrVRZRELyQzrIUAVMHxP97kv+G786pHmOKzuFII8zDYahFBS7qnHh2AlYSl1GAHhaMPCz6/oHjVMcfFYgFYHgA==} dependencies: @@ -19671,7 +19693,6 @@ packages: /path-browserify@1.0.1: resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} - dev: false /path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} @@ -22238,6 +22259,13 @@ packages: /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + /ts-morph@23.0.0: + resolution: {integrity: sha512-FcvFx7a9E8TUe6T3ShihXJLiJOiqyafzFKUO4aqIHDUCIvADdGNShcbc2W5PMr3LerXRv7mafvFZ9lRENxJmug==} + dependencies: + '@ts-morph/common': 0.24.0 + code-block-writer: 13.0.1 + dev: true + /tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} dependencies: diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md index 2f9b4ca05a9..5c03d3c231d 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/aws-function.test.w_test_sim.md @@ -2,7 +2,7 @@ ## stdout.log ```log -pass ─ aws-function.test.wsim » root/env0/test:AWS Function +pass ─ aws-function.test.wsim » root/env0/AWS Function Tests 1 passed (1) Snapshots 1 skipped diff --git a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md index 4679e99f8d7..eeda8ebe4d0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -45,6 +46,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md index c21c0a07975..8c2b8e4688c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $counter, $std_Json }) { class $Closure1 { constructor({ }) { @@ -14,7 +15,7 @@ module.exports = function({ $counter, $std_Json }) { async handle(request) { const count = (await $counter.inc()); const bodyResponse = ({"count": count}); - const resp = ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(bodyResponse), "headers": ({["content-type"]: "application/json"}), "status": 200}); + const resp = ({"body": $macros.__Json_stringify(false, $std_Json, bodyResponse), "headers": ({["content-type"]: "application/json"}), "status": 200}); return resp; } } @@ -27,6 +28,7 @@ module.exports = function({ $counter, $std_Json }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url }) { class $Closure2 { constructor({ }) { @@ -36,7 +38,7 @@ module.exports = function({ $api_url }) { } async handle() { const url = $api_url; - $helpers.assert(url.startsWith("http"), "url.startsWith(\"http\")"); + $helpers.assert($macros.__String_startsWith(false, url, "http"), "url.startsWith(\"http\")"); } } return $Closure2; @@ -48,6 +50,7 @@ module.exports = function({ $api_url }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_3_api_url }) { class $Closure3 { constructor({ }) { @@ -69,6 +72,7 @@ module.exports = function({ $__parent_this_3_api_url }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -476,6 +480,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md index 87d0f929b1c..57f0fed6d16 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $expect_Util, $http_Util }) { class $Closure2 { constructor({ }) { @@ -35,11 +37,11 @@ module.exports = function({ $api_url, $expect_Util, $http_Util }) { const response = (await $http_Util.get(($api_url + "/users"))); const headers = response.headers; (await $expect_Util.equal(response.status, 200)); - (await $expect_Util.equal((headers)["access-control-allow-origin"], "winglang.io")); - (await $expect_Util.equal((headers)["access-control-allow-credentials"], "true")); - (await $expect_Util.equal((headers)["access-control-expose-headers"], "Content-Type")); - (await $expect_Util.nil((headers)["access-control-allow-headers"])); - (await $expect_Util.nil((headers)["access-control-allow-methods"])); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-origin"), "winglang.io")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-credentials"), "true")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-expose-headers"), "Content-Type")); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-headers"))); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-methods"))); } } return $Closure2; @@ -51,6 +53,7 @@ module.exports = function({ $api_url, $expect_Util, $http_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util }) { class $Closure3 { constructor({ }) { @@ -62,11 +65,11 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util const response = (await $http_Util.fetch(($api_url + "/users"), ({"method": $http_HttpMethod.OPTIONS}))); const headers = response.headers; (await $expect_Util.equal(response.status, 204)); - (await $expect_Util.equal((headers)["access-control-allow-methods"], "GET,POST,OPTIONS")); - (await $expect_Util.equal((headers)["access-control-allow-headers"], "Content-Type,Authorization,X-Custom-Header")); - (await $expect_Util.equal((headers)["access-control-allow-origin"], "winglang.io")); - (await $expect_Util.nil((headers)["access-control-expose-headers"])); - (await $expect_Util.nil((headers)["access-control-allow-credentials"])); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-methods"), "GET,POST,OPTIONS")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-headers"), "Content-Type,Authorization,X-Custom-Header")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-origin"), "winglang.io")); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-expose-headers"))); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-credentials"))); } } return $Closure3; @@ -78,6 +81,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util }) { class $Closure4 { constructor({ }) { @@ -89,9 +93,9 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util const response = (await $http_Util.fetch(($api_url + "/users"), ({"method": $http_HttpMethod.OPTIONS, "headers": ({"Access-Control-Request-Method": "PUT", "Access-Control-Request-Headers": "Content-Type,Authorization,X-Custom-Foo"})}))); const headers = response.headers; (await $expect_Util.equal(response.status, 204)); - (await $expect_Util.equal((headers)["access-control-allow-methods"], "GET,POST,OPTIONS")); - (await $expect_Util.equal((headers)["access-control-allow-headers"], "Content-Type,Authorization,X-Custom-Header")); - (await $expect_Util.equal((headers)["access-control-allow-origin"], "winglang.io")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-methods"), "GET,POST,OPTIONS")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-headers"), "Content-Type,Authorization,X-Custom-Header")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-origin"), "winglang.io")); } } return $Closure4; @@ -329,6 +333,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md index 82ea0e4e6a5..64b36f0a1a0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $apiDefaultCors_url, $expect_Util, $http_Util }) { class $Closure2 { constructor({ }) { @@ -35,11 +37,11 @@ module.exports = function({ $apiDefaultCors_url, $expect_Util, $http_Util }) { const response = (await $http_Util.get(($apiDefaultCors_url + "/users"))); const headers = response.headers; (await $expect_Util.equal(response.status, 200)); - (await $expect_Util.equal((headers)["access-control-allow-origin"], "*")); - (await $expect_Util.equal((headers)["access-control-allow-credentials"], "false")); - (await $expect_Util.equal((headers)["access-control-expose-headers"], "")); - (await $expect_Util.nil((headers)["access-control-allow-headers"])); - (await $expect_Util.nil((headers)["access-control-allow-methods"])); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-origin"), "*")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-credentials"), "false")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-expose-headers"), "")); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-headers"))); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-methods"))); } } return $Closure2; @@ -51,6 +53,7 @@ module.exports = function({ $apiDefaultCors_url, $expect_Util, $http_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $apiDefaultCors_url, $expect_Util, $http_HttpMethod, $http_Util }) { class $Closure3 { constructor({ }) { @@ -62,11 +65,11 @@ module.exports = function({ $apiDefaultCors_url, $expect_Util, $http_HttpMethod, const response = (await $http_Util.fetch(($apiDefaultCors_url + "/users"), ({"method": $http_HttpMethod.OPTIONS}))); const headers = response.headers; (await $expect_Util.equal(response.status, 204)); - (await $expect_Util.equal((headers)["access-control-allow-headers"], "Content-Type,Authorization,X-Requested-With")); - (await $expect_Util.equal((headers)["access-control-allow-methods"], "GET,POST,PUT,DELETE,HEAD,OPTIONS")); - (await $expect_Util.equal((headers)["access-control-allow-origin"], "*")); - (await $expect_Util.nil((headers)["access-control-allow-credentials"])); - (await $expect_Util.nil((headers)["access-control-expose-headers"])); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-headers"), "Content-Type,Authorization,X-Requested-With")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-methods"), "GET,POST,PUT,DELETE,HEAD,OPTIONS")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-origin"), "*")); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-credentials"))); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-expose-headers"))); } } return $Closure3; @@ -304,6 +307,7 @@ module.exports = function({ $apiDefaultCors_url, $expect_Util, $http_HttpMethod, ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md index 3411eba057b..fdf38fb69e1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -550,6 +551,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md index ae560f963dd..4341aeac787 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s1, $s2 }) { class $Closure1 { constructor({ }) { @@ -56,6 +57,7 @@ module.exports = function({ $s1, $s2 }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md index ef7b8888f68..ce4b494c6f8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -23,6 +24,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $strToStr }) { class $Closure2 { constructor({ }) { @@ -269,6 +271,7 @@ module.exports = function({ $strToStr }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md index 0bef77200bc..02d42b2b8df 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Baz { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md index a1170c5a559..1e36b21181f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md index 32972797ec6..b78e1f8cde0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class CdkDockerImageFunction { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md index 2e3cb45b79f..97fe2db8c13 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md index c2f8a70f386..2a5f1a8ea2a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -53,6 +54,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md index 7fa81209f3f..e6560c3bcbf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $cdk8s_Chart }) { class Foo extends $cdk8s_Chart { constructor({ }) { @@ -37,6 +38,7 @@ module.exports = function({ $cdk8s_Chart }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -63,6 +65,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md index 0776676dcaa..72a8fc802d7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $greeting, $stuff_HelloWorld }) { class $Closure1 { constructor({ }) { @@ -26,6 +27,7 @@ module.exports = function({ $greeting, $stuff_HelloWorld }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class X { constructor({ }) { @@ -58,6 +60,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md index 3773ece699f..7d5dc4baf53 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_1_b }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $__parent_this_1_b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $store }) { class $Closure1 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $store }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $expect_Util, $file2_Q }) { class $Closure2 { constructor({ }) { @@ -64,6 +67,7 @@ module.exports = function({ $expect_Util, $file2_Q }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Q { constructor({ }) { @@ -81,6 +85,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Store { constructor({ $this_b }) { @@ -99,6 +104,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Triangle { constructor({ }) { @@ -113,6 +119,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Util { constructor({ }) { @@ -127,6 +134,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Util { constructor({ }) { @@ -294,6 +302,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -464,6 +473,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -476,6 +486,7 @@ module.exports = { $preflightTypesMap, }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -598,6 +609,7 @@ module.exports = { $preflightTypesMap, Util, Store, Color }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md index ff340d52ac6..cec76f42163 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Bar { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -32,6 +34,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -46,6 +49,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class InflightClass { async method() { @@ -61,6 +65,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Widget { constructor({ }) { @@ -93,6 +98,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -128,6 +134,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -177,6 +184,7 @@ module.exports = { $preflightTypesMap, Foo }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -250,6 +258,7 @@ module.exports = { $preflightTypesMap, Bar }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -294,6 +303,7 @@ module.exports = { $preflightTypesMap, InflightClass }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -307,6 +317,7 @@ module.exports = { ...module.exports, $preflightTypesMap }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -323,6 +334,7 @@ module.exports = { ...module.exports, $preflightTypesMap }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md index 0b03181a732..edb15d0c086 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Bar { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Baz { constructor({ }) { @@ -32,6 +34,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -46,6 +49,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class InflightBar { } @@ -76,6 +80,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -152,6 +157,7 @@ module.exports = { $preflightTypesMap, Bar, InflightBar }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -195,6 +201,7 @@ module.exports = { $preflightTypesMap, Baz }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -227,6 +234,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md index 3c352400552..e8ef9faebb7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md index c7c33dfa59a..bd0bcaa93ae 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fixture_Store }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $fixture_Store }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $myutil_Util }) { class Store { constructor({ $this_data, $this_handlers }) { @@ -49,6 +51,7 @@ module.exports = function({ $myutil_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Util { constructor({ }) { @@ -101,6 +104,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -169,6 +173,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -188,6 +193,7 @@ module.exports = { $preflightTypesMap, FavoriteNumbers }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -204,7 +210,7 @@ class Store extends $stdlib.std.Resource { return ($extern("@winglibs/testfixture/util.js")["makeKey"])(name) } onSet(handler) { - this.handlers.push(handler); + $macros.__MutArray_push(false, this.handlers, handler); } static _toInflightType() { return ` @@ -255,6 +261,7 @@ module.exports = { $preflightTypesMap, Store }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -268,6 +275,7 @@ module.exports = { ...module.exports, $preflightTypesMap }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -283,6 +291,7 @@ module.exports = { ...module.exports, $preflightTypesMap }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md index 303d2ceca03..055b6db11ab 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -18,11 +19,11 @@ module.exports = function({ $b }) { (await $b.put("foo/bar/", "text")); (await $b.put("foo/bar/baz", "text")); const objs = (await $b.list()); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(objs, 0), "foo"), "objs.at(0) == \"foo\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(objs, 1), "foo/"), "objs.at(1) == \"foo/\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(objs, 2), "foo/bar"), "objs.at(2) == \"foo/bar\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(objs, 3), "foo/bar/"), "objs.at(3) == \"foo/bar/\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(objs, 4), "foo/bar/baz"), "objs.at(4) == \"foo/bar/baz\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, objs, 0), "foo"), "objs.at(0) == \"foo\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, objs, 1), "foo/"), "objs.at(1) == \"foo/\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, objs, 2), "foo/bar"), "objs.at(2) == \"foo/bar\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, objs, 3), "foo/bar/"), "objs.at(3) == \"foo/bar/\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, objs, 4), "foo/bar/baz"), "objs.at(4) == \"foo/bar/baz\""); } } return $Closure1; @@ -66,6 +67,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md index 06a784b991f..1ee42fc1654 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md index 2abf8765e0e..31820679f61 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Bar, $Foo, $foo }) { class $Closure1 { constructor({ }) { @@ -34,6 +35,7 @@ module.exports = function({ $Bar, $Foo, $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Bar { static async bar() { @@ -52,6 +54,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -93,6 +96,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md index ace31abcadb..416bd4587ef 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure2 { constructor({ }) { @@ -46,6 +48,7 @@ module.exports = function({ $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ $this_inflight1 }) { @@ -104,6 +107,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md index ed465698937..f8ae92de88a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $arr, $arrOfMap, $j, $myMap, $mySet }) { class $Closure1 { constructor({ }) { @@ -12,15 +13,15 @@ module.exports = function({ $arr, $arrOfMap, $j, $myMap, $mySet }) { return $obj; } async handle() { - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($arr, 0), "hello"), "arr.at(0) == \"hello\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($arr, 1), "world"), "arr.at(1) == \"world\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $arr, 0), "hello"), "arr.at(0) == \"hello\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $arr, 1), "world"), "arr.at(1) == \"world\""); $helpers.assert($helpers.eq($arr.length, 2), "arr.length == 2"); $helpers.assert((await $mySet.has("my")), "mySet.has(\"my\")"); $helpers.assert($helpers.eq($mySet.size, 2), "mySet.size == 2"); - $helpers.assert(("world" in ($myMap)), "myMap.has(\"world\")"); - $helpers.assert($helpers.eq(Object.keys($myMap).length, 2), "myMap.size() == 2"); - $helpers.assert(("bang" in (((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($arrOfMap, 0))), "arrOfMap.at(0).has(\"bang\")"); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })($j, "b"), "world"), "j.get(\"b\") == \"world\""); + $helpers.assert($macros.__Map_has(false, $myMap, "world"), "myMap.has(\"world\")"); + $helpers.assert($helpers.eq($macros.__Map_size(false, $myMap, ), 2), "myMap.size() == 2"); + $helpers.assert($macros.__Map_has(false, $macros.__Array_at(false, $arrOfMap, 0), "bang"), "arrOfMap.at(0).has(\"bang\")"); + $helpers.assert($helpers.eq($macros.__Json_get(false, $j, "b"), "world"), "j.get(\"b\") == \"world\""); } } return $Closure1; @@ -50,6 +51,7 @@ module.exports = function({ $arr, $arrOfMap, $j, $myMap, $mySet }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md index bd7dd75413c..a76c4c6ef36 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b, $x }) { class $Closure1 { constructor({ }) { @@ -58,6 +59,7 @@ module.exports = function({ $b, $x }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md index 767bde3b6ef..f567ab7fde8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $a, $aCloned, $m, $s }) { class $Closure1 { constructor({ }) { @@ -14,7 +15,7 @@ module.exports = function({ $a, $aCloned, $m, $s }) { async handle() { $helpers.assert($helpers.eq($a.length, 1), "a.length == 1"); $helpers.assert($helpers.eq($s.size, 1), "s.size == 1"); - $helpers.assert($helpers.eq(Object.keys($m).length, 1), "m.size() == 1"); + $helpers.assert($helpers.eq($macros.__Map_size(false, $m, ), 1), "m.size() == 1"); $helpers.assert($helpers.eq($aCloned.length, 1), "aCloned.length == 1"); } } @@ -27,6 +28,7 @@ module.exports = function({ $a, $aCloned, $m, $s }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $handler }) { class $Closure2 { constructor({ }) { @@ -65,6 +67,7 @@ module.exports = function({ $handler }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -160,7 +163,7 @@ class $Root extends $stdlib.std.Resource { const a = ["hello"]; const s = new Set([12]); const m = ({["hello"]: true}); - const aCloned = [...(["hello"])]; + const aCloned = $macros.__Array_copyMut(false, ["hello"], ); const handler = new $Closure1(this, "$Closure1"); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:main", new $Closure2(this, "$Closure2")); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md index 41d7ddd8c45..76d3c190e01 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $myBool, $myDur, $myNum, $mySecondBool, $myStr }) { class $Closure1 { constructor({ }) { @@ -165,6 +166,7 @@ module.exports = function({ $myBool, $myDur, $myNum, $mySecondBool, $myStr }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md index 4fda9176b52..0ae0c20f3d8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -23,6 +24,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $counter }) { class $Closure2 { constructor({ }) { @@ -43,6 +45,7 @@ module.exports = function({ $counter }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $counter, $kv, $util_Util }) { class $Closure3 { constructor({ }) { @@ -73,6 +76,7 @@ module.exports = function({ $counter, $kv, $util_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class KeyValueStore { constructor({ $this_bucket, $this_onUpdateCallback }) { @@ -147,6 +151,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md index 48d30df87ad..c571248327f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $x }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $handler }) { class $Closure2 { constructor({ }) { @@ -62,6 +64,7 @@ module.exports = function({ $handler }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md index 0e41003ac57..c6d0ab8e63f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $data, $queue, $res }) { class $Closure1 { constructor({ }) { @@ -72,6 +73,7 @@ module.exports = function({ $data, $queue, $res }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md index 0a025c561ff..d29f26193a7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $a, $a_field }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $a, $a_field }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ $this_counter }) { @@ -84,6 +86,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md index d1bfd0d67a9..e46a134172a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $r }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $r }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyResource, $api_url, $url }) { class $Closure2 { constructor({ }) { @@ -45,6 +47,7 @@ module.exports = function({ $MyResource, $api_url, $url }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyResource { constructor({ $this_api_url, $this_url }) { @@ -221,6 +224,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md index 76e9c6facfa..7de36390324 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket1, $bucket2, $bucket3 }) { class $Closure1 { constructor({ }) { @@ -38,6 +39,7 @@ module.exports = function({ $bucket1, $bucket2, $bucket3 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $handler }) { class $Closure2 { constructor({ }) { @@ -58,6 +60,7 @@ module.exports = function({ $handler }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $headers }) { class $Closure3 { constructor({ }) { @@ -654,6 +657,7 @@ module.exports = function({ $headers }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md index 9dcb100fe98..19f06e50515 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md @@ -41,6 +41,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/chaining_macros.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/chaining_macros.test.w_compile_tf-aws.md new file mode 100644 index 00000000000..8a7c142a7ac --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/valid/chaining_macros.test.w_compile_tf-aws.md @@ -0,0 +1,210 @@ +# [chaining_macros.test.w](../../../../../examples/tests/valid/chaining_macros.test.w) | compile | tf-aws + +## inflight.$Closure1-1.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); +module.exports = function({ $expect_Util }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const result = ({}); + (await $expect_Util.equal($macros.__Json_tryGet(true, result.item, "id"), undefined)); + (await $expect_Util.equal($macros.__Json_has(true, result.item, "id"), undefined)); + (await $expect_Util.equal($macros.__Json_tryGet(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (await $expect_Util.equal($macros.__Json_has(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (await $expect_Util.equal($macros.__Map_tryGet(true, result.mapItem, "a"), undefined)); + (await $expect_Util.equal($macros.__Map_has(true, result.mapItem, "id"), undefined)); + (await $expect_Util.equal($macros.__Map_tryGet(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (await $expect_Util.equal($macros.__Map_has(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (await $expect_Util.equal(result.setItem?.size, undefined)); + (await $expect_Util.equal((await result.setItem?.has?.(6)), undefined)); + (await $expect_Util.equal($macros.__Array_tryAt(true, result.setItems, 0)?.size, undefined)); + (await $expect_Util.equal((await $macros.__Array_tryAt(true, result.setItems, 0)?.has?.(6)), undefined)); + (await $expect_Util.equal(result.structItem?.item, undefined)); + (await $expect_Util.equal($macros.__Array_tryAt(true, result.structItems, 0)?.item, undefined)); + let calls = 0; + const makeArray = (async () => { + calls = (calls + 1); + return [1, 2, 3]; + }); + (await $expect_Util.ok(($macros.__Array_contains(true, (await makeArray()), 2) ?? false))); + (await $expect_Util.equal(calls, 1)); + } + } + return $Closure1; +} +//# sourceMappingURL=inflight.$Closure1-1.cjs.map +``` + +## inflight.$Closure2-1.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); +module.exports = function({ $expect_Util, $math_Util }) { + class $Closure2 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + const randomChar = $macros.__String_at(false, characters, (await $math_Util.floor(((await $math_Util.random()) * characters.length)))); + const fixedChar = $macros.__String_at(false, characters, (await $math_Util.floor((0.67 * characters.length)))); + (await $expect_Util.equal(fixedChar, "Y")); + } + } + return $Closure2; +} +//# sourceMappingURL=inflight.$Closure2-1.cjs.map +``` + +## main.tf.json +```json +{ + "//": { + "metadata": { + "backend": "local", + "stackName": "root" + }, + "outputs": {} + }, + "provider": { + "aws": [ + {} + ] + } +} +``` + +## preflight.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); +const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); +const $outdir = process.env.WING_SYNTH_DIR ?? "."; +const $wing_is_test = process.env.WING_IS_TEST === "true"; +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); +class $Root extends $stdlib.std.Resource { + constructor($scope, $id) { + super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + const math = $stdlib.math; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; + class $Closure1 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ + $expect_Util: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"))}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType()}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["ok"])], + ], + "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + ], + }); + } + } + class $Closure2 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-1.cjs")({ + $expect_Util: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"))}, + $math_Util: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"))}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure2Client = ${$Closure2._toInflightType()}; + const client = new $Closure2Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), [].concat(["floor"], ["random"])], + ], + "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), []], + ], + }); + } + } + const result = ({}); + (expect.Util.equal($macros.__Json_tryGet(true, result.item, "id"), undefined)); + (expect.Util.equal($macros.__Json_has(true, result.item, "id"), undefined)); + (expect.Util.equal($macros.__Json_tryGet(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (expect.Util.equal($macros.__Json_has(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (expect.Util.equal($macros.__Map_tryGet(true, result.mapItem, "a"), undefined)); + (expect.Util.equal($macros.__Map_has(true, result.mapItem, "id"), undefined)); + (expect.Util.equal($macros.__Map_tryGet(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (expect.Util.equal($macros.__Map_has(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (expect.Util.equal(result.setItem?.size, undefined)); + (expect.Util.equal((result.setItem?.has?.(6)), undefined)); + (expect.Util.equal($macros.__Array_tryAt(true, result.setItems, 0)?.size, undefined)); + (expect.Util.equal(($macros.__Array_tryAt(true, result.setItems, 0)?.has?.(6)), undefined)); + (expect.Util.equal(result.structItem?.item, undefined)); + (expect.Util.equal($macros.__Array_tryAt(true, result.structItems, 0)?.item, undefined)); + let calls = 0; + const makeArray = (() => { + calls = (calls + 1); + return [1, 2, 3]; + }); + (expect.Util.ok(($macros.__Array_contains(true, (makeArray()), 2) ?? false))); + (expect.Util.equal(calls, 1)); + globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:optional chaining macros", new $Closure1(this, "$Closure1")); + globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:nesting and chaining", new $Closure2(this, "$Closure2")); + } +} +const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "chaining_macros.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); +$APP.synth(); +//# sourceMappingURL=preflight.cjs.map +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/chaining_macros.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/chaining_macros.test.w_test_sim.md new file mode 100644 index 00000000000..3d2b4a8b336 --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/valid/chaining_macros.test.w_test_sim.md @@ -0,0 +1,13 @@ +# [chaining_macros.test.w](../../../../../examples/tests/valid/chaining_macros.test.w) | test | sim + +## stdout.log +```log +pass ─ chaining_macros.test.wsim » root/env0/test:optional chaining macros +pass ─ chaining_macros.test.wsim » root/env1/test:nesting and chaining + +Tests 2 passed (2) +Snapshots 1 skipped +Test Files 1 passed (1) +Duration +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md index 04a37a206e3..67836275721 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -67,6 +68,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $c5 }) { class $Closure2 { constructor({ }) { @@ -90,6 +92,7 @@ module.exports = function({ $c5 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $student_hrlyWage, $student_major, $student_name }) { class $Closure3 { constructor({ }) { @@ -112,6 +115,7 @@ module.exports = function({ $student_hrlyWage, $student_major, $student_name }) ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $ta_hrlyWage }) { class $Closure4 { constructor({ }) { @@ -132,6 +136,7 @@ module.exports = function({ $ta_hrlyWage }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $B }) { class $Closure5 { constructor({ }) { @@ -153,6 +158,7 @@ module.exports = function({ $B }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor(sound){ @@ -170,6 +176,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class B extends $A { constructor(sound){ @@ -189,6 +196,7 @@ module.exports = function({ $A }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Boom }) { class Bam extends $Boom { constructor({ }) { @@ -204,6 +212,7 @@ module.exports = function({ $Boom }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Bar { constructor({ }) { @@ -218,6 +227,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class BaseClassWithCtorArg { constructor({ }) { @@ -232,6 +242,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Bar }) { class Baz extends $Bar { constructor({ }) { @@ -247,6 +258,7 @@ module.exports = function({ $Bar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Boom { constructor({ }) { @@ -261,6 +273,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C1 { constructor({ }) { @@ -275,6 +288,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $C1 }) { class C1Ext1 extends $C1 { constructor({ }) { @@ -290,6 +304,7 @@ module.exports = function({ $C1 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $C1Ext1 }) { class C1Ext2 extends $C1Ext1 { constructor({ }) { @@ -305,6 +320,7 @@ module.exports = function({ $C1Ext1 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $C1Ext2 }) { class C1Ext3 extends $C1Ext2 { constructor({ }) { @@ -320,6 +336,7 @@ module.exports = function({ $C1Ext2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C2 { constructor({ }) { @@ -334,6 +351,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $C2 }) { class C2Ext1 extends $C2 { constructor({ }) { @@ -349,6 +367,7 @@ module.exports = function({ $C2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $C2 }) { class C2Ext2 extends $C2 { constructor({ }) { @@ -364,6 +383,7 @@ module.exports = function({ $C2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $C2 }) { class C2Ext3 extends $C2 { constructor({ }) { @@ -379,6 +399,7 @@ module.exports = function({ $C2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C3 { constructor({ }) { @@ -393,6 +414,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C4 { constructor({ }) { @@ -407,6 +429,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C5 { constructor({ }) { @@ -428,6 +451,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $BaseClassWithCtorArg }) { class DerivedClassWithInnerClass extends $BaseClassWithCtorArg { constructor({ }) { @@ -443,6 +467,7 @@ module.exports = function({ $BaseClassWithCtorArg }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class DocClass { constructor({ }) { @@ -457,6 +482,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Bar }) { class Foo extends $Bar { constructor({ }) { @@ -474,6 +500,7 @@ module.exports = function({ $Bar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class InnerBaseClass { constructor({ }) { @@ -488,6 +515,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $InnerBaseClass }) { class InnerDerivedClass extends $InnerBaseClass { constructor({ }) { @@ -503,6 +531,7 @@ module.exports = function({ $InnerBaseClass }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Student }) { class PaidStudent extends $Student { constructor({ }) { @@ -518,6 +547,7 @@ module.exports = function({ $Student }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Person { constructor({ }) { @@ -532,6 +562,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Person }) { class Student extends $Person { constructor({ }) { @@ -547,6 +578,7 @@ module.exports = function({ $Person }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $PaidStudent }) { class TeacherAid extends $PaidStudent { constructor({ }) { @@ -580,6 +612,7 @@ module.exports = function({ $PaidStudent }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md index e9f46e216a9..e40f19c79dc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $fn }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyClosure { constructor({ }) { @@ -66,6 +68,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md index 50ca11a5ef7..b100134fabf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class WingResource { constructor({ }) { @@ -48,6 +49,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md index 5d3868183dd..a244ca5aa21 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md @@ -56,6 +56,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -79,34 +80,34 @@ class $Root extends $stdlib.std.Resource { $helpers.assert($helpers.eq(emptyArray2.length, 0), "emptyArray2.length == 0"); const arr1 = [1, 2, 3]; $helpers.assert($helpers.eq(arr1.length, 3), "arr1.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr1, 1), 2), "arr1.at(1) == 2"); + $helpers.assert($helpers.eq($macros.__Array_at(false, arr1, 1), 2), "arr1.at(1) == 2"); const arr2 = ["1", "2", "3"]; $helpers.assert($helpers.eq(arr2.length, 3), "arr2.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr2, 1), "2"), "arr2.at(1) == \"2\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, arr2, 1), "2"), "arr2.at(1) == \"2\""); const arr3 = [1, 2, 3]; $helpers.assert($helpers.eq(arr3.length, 3), "arr3.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr3, 1), 2), "arr3.at(1) == 2"); + $helpers.assert($helpers.eq($macros.__Array_at(false, arr3, 1), 2), "arr3.at(1) == 2"); const arr4 = [1, 2, 3]; $helpers.assert($helpers.eq(arr4.length, 3), "arr4.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr4, 1), 2), "arr4.at(1) == 2"); + $helpers.assert($helpers.eq($macros.__Array_at(false, arr4, 1), 2), "arr4.at(1) == 2"); const arr5 = [bucket1, bucket2, bucket3]; $helpers.assert($helpers.eq(arr5.length, 3), "arr5.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr5, 1), bucket2), "arr5.at(1) == bucket2"); + $helpers.assert($helpers.eq($macros.__Array_at(false, arr5, 1), bucket2), "arr5.at(1) == bucket2"); const arr6 = [bucket1, bucket2, bucket3]; $helpers.assert($helpers.eq(arr6.length, 3), "arr6.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr6, 1), bucket2), "arr6.at(1) == bucket2"); + $helpers.assert($helpers.eq($macros.__Array_at(false, arr6, 1), bucket2), "arr6.at(1) == bucket2"); const arr7 = arr4; $helpers.assert($helpers.eq(arr7.length, 3), "arr7.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr7, 1), 2), "arr7.at(1) == 2"); + $helpers.assert($helpers.eq($macros.__Array_at(false, arr7, 1), 2), "arr7.at(1) == 2"); { - const $if_let_value = emptyArray.at(0); + const $if_let_value = $macros.__Array_tryAt(false, emptyArray, 0); if ($if_let_value != undefined) { const val = $if_let_value; $helpers.assert(false, "false"); } } { - const $if_let_value = arr1.at(0); + const $if_let_value = $macros.__Array_tryAt(false, arr1, 0); if ($if_let_value != undefined) { const val = $if_let_value; $helpers.assert($helpers.eq(val, 1), "val == 1"); @@ -116,60 +117,60 @@ class $Root extends $stdlib.std.Resource { } } const emptyMap = ({}); - $helpers.assert($helpers.eq(Object.keys(emptyMap).length, 0), "emptyMap.size() == 0"); + $helpers.assert($helpers.eq($macros.__Map_size(false, emptyMap, ), 0), "emptyMap.size() == 0"); const emptyMap2 = ({}); - $helpers.assert($helpers.eq(Object.keys(emptyMap2).length, 0), "emptyMap2.size() == 0"); + $helpers.assert($helpers.eq($macros.__MutMap_size(false, emptyMap2, ), 0), "emptyMap2.size() == 0"); const m1 = ({["a"]: 1, ["b"]: 2, ["c"]: 3}); - $helpers.assert($helpers.eq(Object.keys(m1).length, 3), "m1.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m1, "b"), 2), "m1.get(\"b\") == 2"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m1, ), 3), "m1.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m1, "b"), 2), "m1.get(\"b\") == 2"); const m2 = ({["a"]: 1, ["b"]: 2, ["c"]: 3}); - $helpers.assert($helpers.eq(Object.keys(m2).length, 3), "m2.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m2, "b"), 2), "m2.get(\"b\") == 2"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m2, ), 3), "m2.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m2, "b"), 2), "m2.get(\"b\") == 2"); const m3 = ({["a"]: 1, ["b"]: 2, ["c"]: 3}); - $helpers.assert($helpers.eq(Object.keys(m3).length, 3), "m3.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m3, "b"), 2), "m3.get(\"b\") == 2"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m3, ), 3), "m3.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m3, "b"), 2), "m3.get(\"b\") == 2"); const m4 = ({["a"]: 1, ["b"]: 2, ["c"]: 3}); - $helpers.assert($helpers.eq(Object.keys(m4).length, 3), "m4.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m4, "b"), 2), "m4.get(\"b\") == 2"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m4, ), 3), "m4.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m4, "b"), 2), "m4.get(\"b\") == 2"); const m5 = ({["a"]: bucket1, ["b"]: bucket2, ["c"]: bucket3}); - $helpers.assert($helpers.eq(Object.keys(m5).length, 3), "m5.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m5, "b"), bucket2), "m5.get(\"b\") == bucket2"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m5, ), 3), "m5.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m5, "b"), bucket2), "m5.get(\"b\") == bucket2"); const m6 = ({["a"]: bucket1, ["b"]: bucket2, ["c"]: bucket3}); - $helpers.assert($helpers.eq(Object.keys(m6).length, 3), "m6.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m6, "b"), bucket2), "m6.get(\"b\") == bucket2"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m6, ), 3), "m6.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m6, "b"), bucket2), "m6.get(\"b\") == bucket2"); const m7 = m1; - $helpers.assert($helpers.eq(Object.keys(m7).length, 3), "m7.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m7, "b"), 2), "m7.get(\"b\") == 2"); - $helpers.assert(("b" in (m7)), "m7.has(\"b\")"); - $helpers.assert($helpers.eq(("boom" in (m4)), false), "m4.has(\"boom\") == false"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m7, ), 3), "m7.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m7, "b"), 2), "m7.get(\"b\") == 2"); + $helpers.assert($macros.__Map_has(false, m7, "b"), "m7.has(\"b\")"); + $helpers.assert($helpers.eq($macros.__Map_has(false, m4, "boom"), false), "m4.has(\"boom\") == false"); const m8 = ({["a"]: "a1", ["b"]: "b1", ["c"]: "c1"}); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.keys(m8), 0), "a"), "m8.keys().at(0) == \"a\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.keys(m8), 1), "b"), "m8.keys().at(1) == \"b\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.keys(m8), 2), "c"), "m8.keys().at(2) == \"c\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.values(m8), 0), "a1"), "m8.values().at(0) == \"a1\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.values(m8), 1), "b1"), "m8.values().at(1) == \"b1\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.values(m8), 2), "c1"), "m8.values().at(2) == \"c1\""); - for (const val of Object.keys(m8)) { - $helpers.assert((!val.endsWith("1")), "!val.endsWith(\"1\")"); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__Map_keys(false, m8, ), 0), "a"), "m8.keys().at(0) == \"a\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__Map_keys(false, m8, ), 1), "b"), "m8.keys().at(1) == \"b\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__Map_keys(false, m8, ), 2), "c"), "m8.keys().at(2) == \"c\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__Map_values(false, m8, ), 0), "a1"), "m8.values().at(0) == \"a1\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__Map_values(false, m8, ), 1), "b1"), "m8.values().at(1) == \"b1\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__Map_values(false, m8, ), 2), "c1"), "m8.values().at(2) == \"c1\""); + for (const val of $macros.__Map_keys(false, m8, )) { + $helpers.assert((!$macros.__String_endsWith(false, val, "1")), "!val.endsWith(\"1\")"); } - for (const val of Object.values(m8)) { - $helpers.assert(val.endsWith("1"), "val.endsWith(\"1\")"); + for (const val of $macros.__Map_values(false, m8, )) { + $helpers.assert($macros.__String_endsWith(false, val, "1"), "val.endsWith(\"1\")"); } const m9 = ({["a"]: "a1", ["b"]: "b1", ["c"]: "c1"}); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.keys(m9), 0), "a"), "m9.keys().at(0) == \"a\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.keys(m9), 1), "b"), "m9.keys().at(1) == \"b\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.keys(m9), 2), "c"), "m9.keys().at(2) == \"c\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.values(m9), 0), "a1"), "m9.values().at(0) == \"a1\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.values(m9), 1), "b1"), "m9.values().at(1) == \"b1\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(Object.values(m9), 2), "c1"), "m9.values().at(2) == \"c1\""); - for (const val of Object.keys(m9)) { - $helpers.assert((!val.endsWith("1")), "!val.endsWith(\"1\")"); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__MutMap_keys(false, m9, ), 0), "a"), "m9.keys().at(0) == \"a\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__MutMap_keys(false, m9, ), 1), "b"), "m9.keys().at(1) == \"b\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__MutMap_keys(false, m9, ), 2), "c"), "m9.keys().at(2) == \"c\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__MutMap_values(false, m9, ), 0), "a1"), "m9.values().at(0) == \"a1\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__MutMap_values(false, m9, ), 1), "b1"), "m9.values().at(1) == \"b1\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, $macros.__MutMap_values(false, m9, ), 2), "c1"), "m9.values().at(2) == \"c1\""); + for (const val of $macros.__MutMap_keys(false, m9, )) { + $helpers.assert((!$macros.__String_endsWith(false, val, "1")), "!val.endsWith(\"1\")"); } - for (const val of Object.values(m9)) { - $helpers.assert(val.endsWith("1"), "val.endsWith(\"1\")"); + for (const val of $macros.__MutMap_values(false, m9, )) { + $helpers.assert($macros.__String_endsWith(false, val, "1"), "val.endsWith(\"1\")"); } { - const $if_let_value = (m9)["a"]; + const $if_let_value = $macros.__MutMap_tryGet(false, m9, "a"); if ($if_let_value != undefined) { const k = $if_let_value; $helpers.assert($helpers.eq(k, "a1"), "k == \"a1\""); @@ -179,27 +180,27 @@ class $Root extends $stdlib.std.Resource { } } { - const $if_let_value = (m9)["def-fake"]; + const $if_let_value = $macros.__MutMap_tryGet(false, m9, "def-fake"); if ($if_let_value != undefined) { const k = $if_let_value; $helpers.assert(false, "false"); } } try { - ((obj, key) => { if (!(key in obj)) throw new Error(`MutMap does not contain key: "${key}"`); return obj[key]; })(m9, "def-fake"); + $macros.__MutMap_get(false, m9, "def-fake"); } catch ($error_err) { const err = $error_err.message; - $helpers.assert(err.includes("does not contain key: \"def-fake\""), "err.contains(\"does not contain key: \\\"def-fake\\\"\")"); + $helpers.assert($macros.__String_contains(false, err, "does not contain key: \"def-fake\""), "err.contains(\"does not contain key: \\\"def-fake\\\"\")"); } const num9 = 9; const m10 = ({["a"]: 1, ["a"]: 2, [String.raw({ raw: ["", ""] }, (num9 + 1))]: 9, [String.raw({ raw: ["", ""] }, (num9 + 1))]: 10, [((() => { return String.raw({ raw: ["", "9"] }, num9); })())]: 99}); - $helpers.assert($helpers.eq(Object.keys(m10).length, 3), "m10.size() == 3"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m10, "a"), 2), "m10.get(\"a\") == 2"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m10, "10"), 10), "m10.get(\"10\") == 10"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(m10, "99"), 99), "m10.get(\"99\") == 99"); + $helpers.assert($helpers.eq($macros.__Map_size(false, m10, ), 3), "m10.size() == 3"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m10, "a"), 2), "m10.get(\"a\") == 2"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m10, "10"), 10), "m10.get(\"10\") == 10"); + $helpers.assert($helpers.eq($macros.__Map_get(false, m10, "99"), 99), "m10.get(\"99\") == 99"); const emptySet = new Set([]); $helpers.assert($helpers.eq(emptySet.size, 0), "emptySet.size == 0"); const emptySet2 = new Set([]); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md index 262e27e6876..95b94f80094 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md index cc7916329dc..abfb7809422 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md index ee7e6264189..6aae7739c84 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $numA, $numB, $strA, $strB }) { class $Closure1 { constructor({ }) { @@ -27,6 +28,7 @@ module.exports = function({ $numA, $numB, $strA, $strB }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $arrayA, $arrayB }) { class $Closure10 { constructor({ }) { @@ -48,6 +50,7 @@ module.exports = function({ $arrayA, $arrayB }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $arrayA, $arrayB, $arrayC }) { class $Closure11 { constructor({ }) { @@ -69,6 +72,7 @@ module.exports = function({ $arrayA, $arrayB, $arrayC }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $cat1, $cat2 }) { class $Closure12 { constructor({ }) { @@ -90,6 +94,7 @@ module.exports = function({ $cat1, $cat2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $cat1, $cat2, $cat3 }) { class $Closure13 { constructor({ }) { @@ -111,6 +116,7 @@ module.exports = function({ $cat1, $cat2, $cat3 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $numA, $numC, $strA, $strC }) { class $Closure2 { constructor({ }) { @@ -132,6 +138,7 @@ module.exports = function({ $numA, $numC, $strA, $strC }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $jsonA, $jsonB }) { class $Closure3 { constructor({ }) { @@ -153,6 +160,7 @@ module.exports = function({ $jsonA, $jsonB }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $jsonA, $jsonB, $jsonC }) { class $Closure4 { constructor({ }) { @@ -174,6 +182,7 @@ module.exports = function({ $jsonA, $jsonB, $jsonC }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $std_Json }) { class $Closure5 { constructor({ }) { @@ -183,7 +192,7 @@ module.exports = function({ $std_Json }) { } async handle() { const j = ({"hello": 123, "world": [1, 2, 3]}); - $helpers.assert($helpers.eq(Object.values(j), [123, [1, 2, 3]]), "Json.values(j) == [Json 123, Json [1, 2, 3]]"); + $helpers.assert($helpers.eq($macros.__Json_values(false, $std_Json, j), [123, [1, 2, 3]]), "Json.values(j) == [Json 123, Json [1, 2, 3]]"); } } return $Closure5; @@ -195,6 +204,7 @@ module.exports = function({ $std_Json }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $setA, $setB }) { class $Closure6 { constructor({ }) { @@ -216,6 +226,7 @@ module.exports = function({ $setA, $setB }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $setA, $setB, $setC }) { class $Closure7 { constructor({ }) { @@ -237,6 +248,7 @@ module.exports = function({ $setA, $setB, $setC }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $mapA, $mapB }) { class $Closure8 { constructor({ }) { @@ -258,6 +270,7 @@ module.exports = function({ $mapA, $mapB }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $mapA, $mapB, $mapC }) { class $Closure9 { constructor({ }) { @@ -297,6 +310,7 @@ module.exports = function({ $mapA, $mapB, $mapC }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md index b649c7dfd86..d70e646414b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bar, $bar_foo, $initCount }) { class $Closure1 { constructor({ }) { @@ -26,6 +27,7 @@ module.exports = function({ $bar, $bar_foo, $initCount }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Bar { constructor({ $this_foo }) { @@ -44,6 +46,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $initCount }) { class Foo { constructor({ }) { @@ -102,6 +105,7 @@ module.exports = function({ $initCount }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md index 39c081fffcd..f133484b792 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $handler, $std_Number }) { class $Closure2 { constructor({ }) { @@ -47,6 +49,7 @@ module.exports = function({ $handler, $std_Number }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure3 { constructor({ }) { @@ -67,6 +70,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure4 { constructor({ }) { @@ -88,6 +92,7 @@ module.exports = function({ $f }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Doubler { constructor({ $this_func }) { @@ -108,6 +113,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Doubler2 { constructor({ }) { @@ -249,6 +255,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md index be2a87a5535..6d994c1715f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $SomeEnum, $one, $two }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $SomeEnum, $one, $two }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $SomeEnum }) { class $Closure2 { constructor({ }) { @@ -65,6 +67,7 @@ module.exports = function({ $SomeEnum }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md index 2950dddf3fc..19bccde1a3c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket1 }) { class $Closure2 { constructor({ }) { @@ -48,6 +50,7 @@ module.exports = function({ $bucket1 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $inflight_closure }) { class $Closure3 { constructor({ }) { @@ -68,6 +71,7 @@ module.exports = function({ $inflight_closure }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bar }) { class $Closure4 { constructor({ }) { @@ -91,6 +95,7 @@ module.exports = function({ $bar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket1, $bucket2, $bucket3, $maybe_bucket }) { class Foo { constructor({ }) { @@ -125,6 +130,7 @@ module.exports = function({ $bucket1, $bucket2, $bucket3, $maybe_bucket }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class PreflightClass { constructor({ }) { @@ -207,6 +213,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md index 108ed86aa96..f8fe4dbd711 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md index fa108f2575b..1b4d0513c64 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $expect_Util, $number }) { class $Closure1 { constructor({ }) { @@ -47,6 +48,7 @@ module.exports = function({ $expect_Util, $number }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md index 51461f42d18..dc266f036ed 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $cdk8s_Chart }) { class Foo extends $cdk8s_Chart { constructor({ }) { @@ -19,6 +20,7 @@ module.exports = function({ $cdk8s_Chart }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md index ac289a68938..23423be2acc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $f }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $func }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $func }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure3 { constructor({ }) { @@ -64,6 +67,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -233,6 +237,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md index 7d4fe8c485a..6479343c632 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket, $counter }) { class $Closure1 { constructor({ }) { @@ -213,6 +214,7 @@ module.exports = function({ $bucket, $counter }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md index c5028422948..6d794d3f688 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -28,6 +29,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -174,6 +176,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md index 2c3c1b59d08..90fb666e6ac 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class R { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md index f9d85f005f9..f2eb0133217 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md index 0e438a4d385..11114fb59be 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -50,6 +51,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md index 99efb660340..48977bee92d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -23,6 +24,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure2 { constructor({ }) { @@ -42,6 +44,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure3 { constructor({ }) { @@ -61,6 +64,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C { constructor({ }) { @@ -97,6 +101,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md index 429589b3da2..d49d1ee3fef 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class B extends $A { constructor({ }) { @@ -85,6 +87,7 @@ module.exports = function({ $A }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -173,8 +176,8 @@ class $Root extends $stdlib.std.Resource { for (const i of args) { $helpers.assert(((i > 0) && (i < 5)), "i > 0 && i < 5"); } - args.push(10); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(args, 4), 10), "args.at(4) == 10"); + $macros.__MutArray_push(false, args, 10); + $helpers.assert($helpers.eq($macros.__MutArray_at(false, args, 4), 10), "args.at(4) == 10"); }); (func1(1, "something", 1, 2, 3, 4)); (func1(1, undefined, 1, 2, 3, 4)); @@ -190,7 +193,7 @@ class $Root extends $stdlib.std.Resource { const arityFunc = ((n, b, ...events) => { let error = false; try { - ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(events, (-1)); + $macros.__Array_at(false, events, (-1)); } catch ($error_ex) { const ex = $error_ex.message; @@ -200,13 +203,13 @@ class $Root extends $stdlib.std.Resource { }); (arityFunc(1, true, "a", "b", "c", "d")); const subTypeFunc = ((...events) => { - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(events, 0).message, "this is A"), "events.at(0).message == \"this is A\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(events, 1).message, "this is B"), "events.at(1).message == \"this is B\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, events, 0).message, "this is A"), "events.at(0).message == \"this is A\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, events, 1).message, "this is B"), "events.at(1).message == \"this is B\""); }); (subTypeFunc(new A(this, "A", "this is A"), new B(this, "B", "this is B"))); const jsonCastingFunc = ((...events) => { - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(events, 0), "str"), "events.at(0) == \"str\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(events, 1), "json str"), "events.at(1) == \"json str\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, events, 0), "str"), "events.at(0) == \"str\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, events, 1), "json str"), "events.at(1) == \"json str\""); }); const jsonStr = "json str"; (jsonCastingFunc("str", jsonStr)); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md index bdf659d10c1..4df80ddda2f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket }) { class $Closure1 { constructor({ }) { @@ -191,6 +192,7 @@ module.exports = function({ $bucket }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md index f12415d9506..6fb5a996e12 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -23,6 +24,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure2 { constructor({ }) { @@ -60,6 +62,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md index e575d1268d8..4176ef61e96 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $x }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $i3 }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $i3 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure3 { constructor({ }) { @@ -70,6 +73,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure4 { constructor({ }) { @@ -89,6 +93,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -109,6 +114,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Dog { constructor({ }) { @@ -126,6 +132,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class ImplInflightIfaceInInflightClass { async inflight_method() { @@ -141,6 +148,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class ImplInflightIfaceInPreflightClass { constructor({ }) { @@ -158,6 +166,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class ImplPreflightIfaceInPreflightClass { constructor({ }) { @@ -172,6 +181,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class ImplementInflightIfaceInPreflightClass { constructor({ }) { @@ -189,6 +199,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class ImplementJsiiIface { constructor({ }) { @@ -206,6 +217,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Dog }) { class Terrier extends $Dog { constructor({ }) { @@ -224,6 +236,7 @@ module.exports = function({ $Dog }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class r { constructor({ }) { @@ -259,6 +272,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md index 9e19a3cf64b..7c6a55a96d6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -36,7 +37,7 @@ class $Root extends $stdlib.std.Resource { let $preflightTypesMap = {}; $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const d = (std.Duration.fromMinutes(5)); - const n = ((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return Number(args) })("12"); + const n = $macros.__Number_fromStr(false, std.Number, "12"); $helpers.assert($helpers.eq(d.seconds, (5 * 60)), "d.seconds == 5 * 60"); $helpers.assert($helpers.eq(n, 12), "n == 12"); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md index 6a29525ff78..f885474f1d3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyClass { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md index 69b5dc2bf15..2f4b57aa9d3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md index 9f7f5843c7d..1c35fa2afbc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -250,6 +251,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -309,13 +311,13 @@ class $Root extends $stdlib.std.Resource { const emptyArray = []; const num_array = emptyArray; const emptyArray2 = []; - const clonedArray2 = [...(emptyArray2)]; - clonedArray2.push(1); - clonedArray2.push(2); - clonedArray2.push((((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(clonedArray2, 0) + ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(clonedArray2, 1))); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(clonedArray2, 2), 3), "clonedArray2.at(2) == 3"); - const emptySet = new Set([((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(clonedArray2, 2)]); - const clonedSet = new Set(emptySet); + const clonedArray2 = $macros.__Array_copyMut(false, emptyArray2, ); + $macros.__MutArray_push(false, clonedArray2, 1); + $macros.__MutArray_push(false, clonedArray2, 2); + $macros.__MutArray_push(false, clonedArray2, ($macros.__MutArray_at(false, clonedArray2, 0) + $macros.__MutArray_at(false, clonedArray2, 1))); + $helpers.assert($helpers.eq($macros.__MutArray_at(false, clonedArray2, 2), 3), "clonedArray2.at(2) == 3"); + const emptySet = new Set([$macros.__MutArray_at(false, clonedArray2, 2)]); + const clonedSet = $macros.__Set_copyMut(false, emptySet, ); (clonedSet.add(4)); const api = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Api", cloud.Api, this, "Api"); const func = new $Closure1(this, "$Closure1"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md index b2a21ff6112..925f0fd52ac 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure2 { constructor({ }) { @@ -322,6 +324,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md index 515972fd31d..b9df1717322 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Preflight }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $Preflight }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $OuterInflight }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $OuterInflight }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure3 { constructor({ }) { @@ -69,6 +72,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $util_Util }) { class $Closure4 { constructor({ }) { @@ -98,6 +102,7 @@ module.exports = function({ $util_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class OuterInflight { static async staticMethod(b) { @@ -113,6 +118,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Preflight { constructor({ }) { @@ -148,6 +154,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md index 1f57973c049..80c0c5d7d19 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $getBar }) { class $Closure2 { constructor({ }) { @@ -45,6 +47,7 @@ module.exports = function({ $getBar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { async get() { @@ -78,6 +81,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md index 318d04b3747..fa06a4704ba 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo, $myConst }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $Foo, $myConst }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $myConst }) { class Foo { async getValue() { @@ -58,6 +60,7 @@ module.exports = function({ $myConst }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index feba859a616..389b00b6086 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure2 { constructor({ }) { @@ -45,6 +47,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure3 { constructor({ }) { @@ -65,6 +68,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $getFoo }) { class $Closure4 { constructor({ }) { @@ -86,6 +90,7 @@ module.exports = function({ $getFoo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure5 { constructor({ }) { @@ -113,6 +118,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $subdir_InflightClass }) { class $Closure6 { constructor({ }) { @@ -134,6 +140,7 @@ module.exports = function({ $subdir_InflightClass }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Bar { constructor({ }) { @@ -148,6 +155,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -162,6 +170,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -176,6 +185,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class Foo { async uploadToBucket(k, value) { @@ -196,6 +206,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class InflightClass { async method() { @@ -211,6 +222,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Widget { constructor({ }) { @@ -257,6 +269,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -548,6 +561,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -597,6 +611,7 @@ module.exports = { $preflightTypesMap, Foo }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -670,6 +685,7 @@ module.exports = { $preflightTypesMap, Bar }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -714,6 +730,7 @@ module.exports = { $preflightTypesMap, InflightClass }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -727,6 +744,7 @@ module.exports = { ...module.exports, $preflightTypesMap }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -743,6 +761,7 @@ module.exports = { ...module.exports, $preflightTypesMap }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md index 94879057709..c0d04a7c282 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -30,6 +31,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $F }) { class $Closure2 { constructor({ }) { @@ -50,6 +52,7 @@ module.exports = function({ $F }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $B, $a, $d, $fn, $innerD }) { class $Closure3 { constructor({ }) { @@ -75,6 +78,7 @@ module.exports = function({ $B, $a, $d, $fn, $innerD }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -92,6 +96,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class B { async foo() { @@ -107,6 +112,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class D { constructor({ $this_inner }) { @@ -125,6 +131,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class E { constructor({ }) { @@ -139,6 +146,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class F { async foo() { @@ -172,6 +180,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md index 27c86f77865..13b99291454 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -16,13 +17,13 @@ module.exports = function({ }) { let i = 10; class Inner { async dang() { - y.push(2); + $macros.__MutArray_push(false, y, 2); i = (i + 1); - return (((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(y, 0) + 10); + return ($macros.__MutArray_at(false, y, 0) + 10); } } $helpers.assert($helpers.eq((await (await (async () => {const o = new Inner(); await o.$inflight_init?.(); return o; })()).dang()), 11), "new Inner().dang() == 11"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(y, 1), 2), "y.at(1) == 2"); + $helpers.assert($helpers.eq($macros.__MutArray_at(false, y, 1), 2), "y.at(1) == 2"); $helpers.assert($helpers.eq(i, 11), "i == 11"); } } @@ -53,6 +54,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md index 81dfcb0c04e..9bb5e3bf76f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_1_b }) { class $Closure1 { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ $__parent_this_1_b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure2 { constructor({ }) { @@ -56,6 +58,7 @@ module.exports = function({ $f }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure3 { constructor({ }) { @@ -84,6 +87,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class PreflightClass { constructor({ }) { @@ -236,6 +240,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md index 7a7f902f2ee..bb747b7733d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C { async method() { @@ -41,6 +42,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md index 47ab9391107..bb35b18fa79 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $BinaryOperation }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $BinaryOperation }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class BinaryOperation { async add() { @@ -64,6 +66,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md index c765e59595e..8d38b288aef 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $NotGoo }) { class $Closure1 { constructor({ }) { @@ -35,6 +36,7 @@ module.exports = function({ $NotGoo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class NotGoo { async handle() { @@ -68,6 +70,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md index 1a42a36b749..a9ebebfd147 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { } @@ -54,6 +56,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md index 90920877bb4..5e8504c5b7a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $c_h }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $c_h }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Base { constructor({ }) { @@ -58,6 +61,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Base }) { class Derived extends $Base { constructor({ }) { @@ -73,6 +77,7 @@ module.exports = function({ $Base }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -105,6 +110,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -274,8 +280,8 @@ class $Root extends $stdlib.std.Resource { } } const c = new Derived(this, "derived"); - $helpers.assert($helpers.nodeof(c.f).path.endsWith("derived/in_derived"), "nodeof(c.f).path.endsWith(\"derived/in_derived\")"); - $helpers.assert((!$helpers.nodeof(c.f_base).path.endsWith("derived/in_root")), "!nodeof(c.f_base).path.endsWith(\"derived/in_root\")"); + $helpers.assert($macros.__String_endsWith(false, $helpers.nodeof(c.f).path, "derived/in_derived"), "nodeof(c.f).path.endsWith(\"derived/in_derived\")"); + $helpers.assert((!$macros.__String_endsWith(false, $helpers.nodeof(c.f_base).path, "derived/in_root")), "!nodeof(c.f_base).path.endsWith(\"derived/in_root\")"); const appPath = $helpers.nodeof(this).path; $helpers.assert($helpers.eq($helpers.nodeof(c.f_base).path, String.raw({ raw: ["", "/in_root"] }, appPath)), "nodeof(c.f_base).path == \"{appPath}/in_root\""); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:boom!", new $Closure2(this, "$Closure2")); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md index 44fd693a882..604b7635634 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $i }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $i }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $inflights }) { class $Closure2 { constructor({ }) { @@ -33,7 +35,7 @@ module.exports = function({ $inflights }) { } async handle() { for (const i of $helpers.range(0,5,false)) { - $helpers.assert($helpers.eq((await ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($inflights, i)()), i), "inflights.at(i)() == i"); + $helpers.assert($helpers.eq((await $macros.__Array_at(false, $inflights, i)()), i), "inflights.at(i)() == i"); } } } @@ -64,6 +66,7 @@ module.exports = function({ $inflights }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -149,7 +152,7 @@ class $Root extends $stdlib.std.Resource { }); } } - inflights.push(new $Closure1(this, "$Closure1")); + $macros.__MutArray_push(false, inflights, new $Closure1(this, "$Closure1")); } globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight closure auto id", new $Closure2(this, "$Closure2")); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md index d8ce03e1d6e..838ec901950 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -23,6 +24,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -55,6 +57,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md index 3f831aa1739..4943e0dbfd5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class R { constructor({ $this_s1 }) { @@ -40,6 +41,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md index e21b6ab5714..85f05fd32ef 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure2 { constructor({ }) { @@ -46,6 +48,7 @@ module.exports = function({ $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $expect_Util, $fn, $fn2, $sim }) { class $Closure3 { constructor({ }) { @@ -74,6 +77,7 @@ module.exports = function({ $expect_Util, $fn, $fn2, $sim }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo, $std_Duration, $util_Util }) { class $Closure4 { constructor({ }) { @@ -96,6 +100,7 @@ module.exports = function({ $foo, $std_Duration, $util_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn3, $std_Duration, $util_Util }) { class $Closure5 { constructor({ }) { @@ -118,6 +123,7 @@ module.exports = function({ $fn3, $std_Duration, $util_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -437,6 +443,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md index efdd00562ab..65ec2dfa994 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $FooChild }) { class $Closure2 { constructor({ }) { @@ -46,6 +48,7 @@ module.exports = function({ $FooChild }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure3 { constructor({ }) { @@ -82,6 +85,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $jsii_fixture_JsiiClass }) { class $Closure4 { constructor({ }) { @@ -127,6 +131,7 @@ module.exports = function({ $jsii_fixture_JsiiClass }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { async get_six() { @@ -148,6 +153,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class FooChild extends $Foo { constructor(){ @@ -186,6 +192,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md index 24e3c43e6ba..72f43f0c486 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $globalBucket }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $globalBucket }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $storeInBucket }) { class $Closure2 { constructor({ }) { @@ -33,7 +35,7 @@ module.exports = function({ $storeInBucket }) { } async handle(event) { { - const $if_let_value = ((arg) => { return (typeof arg === "string") ? JSON.parse(JSON.stringify(arg)) : undefined })(event); + const $if_let_value = $macros.__Json_tryAsStr(true, event, ); if ($if_let_value != undefined) { const event = $if_let_value; (await $storeInBucket(event, "file1")); @@ -50,6 +52,7 @@ module.exports = function({ $storeInBucket }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $func1, $globalBucket }) { class $Closure3 { constructor({ }) { @@ -71,6 +74,7 @@ module.exports = function({ $func1, $globalBucket }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $globalBucket }) { class $Closure4 { constructor({ }) { @@ -92,6 +96,7 @@ module.exports = function({ $globalBucket }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $x }) { class $Closure5 { constructor({ }) { @@ -113,6 +118,7 @@ module.exports = function({ $x }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyResource { constructor({ $this_closure }) { @@ -269,6 +275,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md index 8e1d429424a..e6e5817960d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $http_Util }) { class $Closure2 { constructor({ }) { @@ -45,6 +47,7 @@ module.exports = function({ $api_url, $http_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $cloud_Api }) { class AnApi extends $cloud_Api { constructor({ }) { @@ -286,6 +289,7 @@ module.exports = function({ $cloud_Api }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md index 9e549d0530f..9169e685008 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $expect_Util, $foo }) { class $Closure1 { constructor({ }) { @@ -26,6 +27,7 @@ module.exports = function({ $expect_Util, $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $FooBase }) { class Foo extends $FooBase { constructor({ }) { @@ -47,6 +49,7 @@ module.exports = function({ $FooBase }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class FooBase { constructor({ }) { @@ -85,6 +88,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md index 395c25635da..c610b24fe9e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $FooBase }) { class Foo extends $FooBase { constructor({ }) { @@ -19,6 +20,7 @@ module.exports = function({ $FooBase }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class FooBase { constructor({ }) { @@ -51,6 +53,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md index 664719d042b..69fc74b36fa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Baz { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md index e0969ca0a05..b92c25e9c9f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class D { constructor({ }) { @@ -50,6 +52,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md index a02d9633f77..04708263973 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $echo }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $echo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $func, $funcFunction }) { class $Closure2 { constructor({ }) { @@ -45,6 +47,7 @@ module.exports = function({ $func, $funcFunction }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Bar { constructor({ }) { @@ -59,6 +62,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $counter }) { class Example { constructor({ }) { @@ -79,6 +83,7 @@ module.exports = function({ $counter }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class InflightBar { } @@ -238,6 +243,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -314,6 +320,7 @@ module.exports = { $preflightTypesMap, Bar, InflightBar }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md index 1eb261b31ec..2cdc9fd8b5a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $std_Json }) { class $Closure1 { constructor({ }) { @@ -12,8 +13,8 @@ module.exports = function({ $std_Json }) { return $obj; } async handle(req) { - const issues = JSON.parse("[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}, {\"foo\": \"qux\"}]"); - return ({"status": 200, "headers": ({["Content-Type"]: "application/json"}), "body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(issues)}); + const issues = $macros.__Json_parse(false, $std_Json, "[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}, {\"foo\": \"qux\"}]"); + return ({"status": 200, "headers": ({["Content-Type"]: "application/json"}), "body": $macros.__Json_stringify(false, $std_Json, issues)}); } } return $Closure1; @@ -25,6 +26,7 @@ module.exports = function({ $std_Json }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $http_Util, $std_Json }) { class $Closure2 { constructor({ }) { @@ -34,9 +36,9 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { } async handle() { const res = (await $http_Util.get(($api_url + "/foo"))); - const body = JSON.parse(res.body); - const a1 = ((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(body, 0); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(a1, "foo"), "bar"), "a1.get(\"foo\") == \"bar\""); + const body = $macros.__Json_parse(false, $std_Json, res.body); + const a1 = $macros.__Json_getAt(false, body, 0); + $helpers.assert($helpers.eq($macros.__Json_get(false, a1, "foo"), "bar"), "a1.get(\"foo\") == \"bar\""); } } return $Closure2; @@ -274,6 +276,7 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md index 2a9362a0937..8f9daf81ada 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -60,6 +61,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -109,12 +111,12 @@ class $Root extends $stdlib.std.Resource { const jsonMap = ({["1"]: 1, ["2"]: 2, ["3"]: 3}); const jsonObj = ({"boom": 123}); for (const j of [jsonNumber, jsonBool, jsonArray, jsonMap, jsonObj]) { - $helpers.assert($helpers.eq(j, JSON.parse(((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(j))), "j == Json.parse(Json.stringify(j))"); + $helpers.assert($helpers.eq(j, $macros.__Json_parse(false, std.Json, $macros.__Json_stringify(false, std.Json, j))), "j == Json.parse(Json.stringify(j))"); } const jsonMutObj = ({"hello": 123, "world": [1, "cat", 3], "boom boom": ({"hello": 1233})}); const message = "Coolness"; - ((obj, key, value) => { obj[key] = value; })(jsonMutObj, "hello", message); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(jsonMutObj, "hello"), message), "jsonMutObj.get(\"hello\") == message"); + $macros.__MutJson_set(false, jsonMutObj, "hello", message); + $helpers.assert($helpers.eq($macros.__MutJson_get(false, jsonMutObj, "hello"), message), "jsonMutObj.get(\"hello\") == message"); const someNumber = 999; const jj = someNumber; const jj1 = ({"foo": someNumber}); @@ -128,37 +130,37 @@ class $Root extends $stdlib.std.Resource { const jj4 = f.SumStr; $helpers.assert($helpers.eq(jj4, "wow!"), "jj4 == Json \"wow!\""); const someJson = ({"x": someNumber}); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(someJson, "x"), someNumber), "someJson.get(\"x\") == someNumber"); - ((obj, key, value) => { obj[key] = value; })(someJson, "x", 111); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(someJson, "x"), 111), "someJson.get(\"x\") == 111"); + $helpers.assert($helpers.eq($macros.__MutJson_get(false, someJson, "x"), someNumber), "someJson.get(\"x\") == someNumber"); + $macros.__MutJson_set(false, someJson, "x", 111); + $helpers.assert($helpers.eq($macros.__MutJson_get(false, someJson, "x"), 111), "someJson.get(\"x\") == 111"); const x = ({"cool": "beans"}); const nestedJson = ({"a": "hello", "b": ({"c": "world", "d": ({"foo": "foo", "bar": 123})})}); - ((obj, key, value) => { obj[key] = value; })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(nestedJson, "b"), "d"), "foo", "tastic"); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(nestedJson, "b"), "d"), "foo"), "tastic"), "nestedJson.get(\"b\").get(\"d\").get(\"foo\") == \"tastic\""); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(nestedJson, "b"), "d"), "bar"), 123), "nestedJson.get(\"b\").get(\"d\").get(\"bar\") == 123"); + $macros.__MutJson_set(false, $macros.__MutJson_get(false, $macros.__MutJson_get(false, nestedJson, "b"), "d"), "foo", "tastic"); + $helpers.assert($helpers.eq($macros.__MutJson_get(false, $macros.__MutJson_get(false, $macros.__MutJson_get(false, nestedJson, "b"), "d"), "foo"), "tastic"), "nestedJson.get(\"b\").get(\"d\").get(\"foo\") == \"tastic\""); + $helpers.assert($helpers.eq($macros.__MutJson_get(false, $macros.__MutJson_get(false, $macros.__MutJson_get(false, nestedJson, "b"), "d"), "bar"), 123), "nestedJson.get(\"b\").get(\"d\").get(\"bar\") == 123"); const b = "buckle"; const arr = [1, 2, b, "my", "shoe", 3, 4, ["shut", "the", "door"]]; - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(arr, 0), 1), "arr.getAt(0) == 1"); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(arr, 2), b), "arr.getAt(2) == b"); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(arr, 7), 0), "shut"), "arr.getAt(7).getAt(0) == \"shut\""); + $helpers.assert($helpers.eq($macros.__Json_getAt(false, arr, 0), 1), "arr.getAt(0) == 1"); + $helpers.assert($helpers.eq($macros.__Json_getAt(false, arr, 2), b), "arr.getAt(2) == b"); + $helpers.assert($helpers.eq($macros.__Json_getAt(false, $macros.__Json_getAt(false, arr, 7), 0), "shut"), "arr.getAt(7).getAt(0) == \"shut\""); ({"a": [1, 2, "world"], "b": [1, 2, "world"]}); const emptyJson = ({}); const emptyJsonArr = []; const emptyMutJson = ({}); const emptyMutJsonArr = []; - ((obj, key, value) => { obj[key] = value; })(emptyMutJson, "cool", ({"a": 1, "b": 2})); - ((obj, key, value) => { obj[key] = value; })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(emptyMutJson, "cool"), "a", 3); - ((obj, idx, value) => { obj[idx] = value; })(emptyMutJsonArr, 0, ({"a": 1, "b": 2})); - ((obj, key, value) => { obj[key] = value; })(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(emptyMutJsonArr, 0), "a", 3); + $macros.__MutJson_set(false, emptyMutJson, "cool", ({"a": 1, "b": 2})); + $macros.__MutJson_set(false, $macros.__MutJson_get(false, emptyMutJson, "cool"), "a", 3); + $macros.__MutJson_setAt(false, emptyMutJsonArr, 0, ({"a": 1, "b": 2})); + $macros.__MutJson_set(false, $macros.__MutJson_getAt(false, emptyMutJsonArr, 0), "a", 3); const theTowerOfJson = ({"a": ({}), "b": ({"c": ({}), "d": [[[({})]]]}), "e": ({"f": ({"g": ({}), "h": [({}), []]})})}); - ((obj, key, value) => { obj[key] = value; })(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(theTowerOfJson, "e"), "f"), "h"), 0), "a", 1); - const thatSuperNestedValue = ((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(theTowerOfJson, "e"), "f"), "h"), 0), "a"); + $macros.__MutJson_set(false, $macros.__MutJson_getAt(false, $macros.__MutJson_get(false, $macros.__MutJson_get(false, $macros.__MutJson_get(false, theTowerOfJson, "e"), "f"), "h"), 0), "a", 1); + const thatSuperNestedValue = $macros.__MutJson_get(false, $macros.__MutJson_getAt(false, $macros.__MutJson_get(false, $macros.__MutJson_get(false, $macros.__MutJson_get(false, theTowerOfJson, "e"), "f"), "h"), 0), "a"); $helpers.assert($helpers.eq((std.Number.fromJson(thatSuperNestedValue)), 1), "num.fromJson(thatSuperNestedValue) == 1"); const unestedJsonArr = [1, 2, 3]; - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(unestedJsonArr, 0), 1), "unestedJsonArr.getAt(0) == 1"); + $helpers.assert($helpers.eq($macros.__Json_getAt(false, unestedJsonArr, 0), 1), "unestedJsonArr.getAt(0) == 1"); const jsonElements = ({"strings": ({"single": "Hello", "array": ["Hello", "World", "!"]}), "numbers": ({"one": 1, "two": 2, "three": 3}), "bools": ({"t": true, "f": false})}); { - const $if_let_value = ((arg) => { if (typeof arg !== "string") {throw new Error("unable to parse " + typeof arg + " " + arg + " as a string")}; return JSON.parse(JSON.stringify(arg)) })(((jsonElements)?.["strings"])?.["single"]); + const $if_let_value = $macros.__Json_asStr(true, $macros.__Json_tryGet(true, $macros.__Json_tryGet(false, jsonElements, "strings"), "single"), ); if ($if_let_value != undefined) { const val = $if_let_value; $helpers.assert($helpers.eq(val, "Hello"), "val == \"Hello\""); @@ -168,11 +170,11 @@ class $Root extends $stdlib.std.Resource { } } { - const $if_let_value = ((jsonElements)?.["strings"])?.["array"]; + const $if_let_value = $macros.__Json_tryGet(true, $macros.__Json_tryGet(false, jsonElements, "strings"), "array"); if ($if_let_value != undefined) { const vals = $if_let_value; { - const $if_let_value = (vals)?.[0]; + const $if_let_value = $macros.__Json_tryGetAt(false, vals, 0); if ($if_let_value != undefined) { const hello = $if_let_value; $helpers.assert($helpers.eq(hello, "Hello"), "hello == \"Hello\""); @@ -187,7 +189,7 @@ class $Root extends $stdlib.std.Resource { } } { - const $if_let_value = ((arg) => { return (typeof arg === "number") ? JSON.parse(JSON.stringify(arg)) : undefined })(((jsonElements)?.["numbers"])?.["two"]); + const $if_let_value = $macros.__Json_tryAsNum(true, $macros.__Json_tryGet(true, $macros.__Json_tryGet(false, jsonElements, "numbers"), "two"), ); if ($if_let_value != undefined) { const two = $if_let_value; $helpers.assert($helpers.eq((two + 2), 4), "two + 2 == 4"); @@ -197,7 +199,7 @@ class $Root extends $stdlib.std.Resource { } } { - const $if_let_value = ((arg) => { return (typeof arg === "boolean") ? JSON.parse(JSON.stringify(arg)) : undefined })(((jsonElements)?.["bools"])?.["t"]); + const $if_let_value = $macros.__Json_tryAsBool(true, $macros.__Json_tryGet(true, $macros.__Json_tryGet(false, jsonElements, "bools"), "t"), ); if ($if_let_value != undefined) { const truth = $if_let_value; $helpers.assert(truth, "truth"); @@ -207,23 +209,23 @@ class $Root extends $stdlib.std.Resource { } } { - const $if_let_value = ((((jsonElements)?.["strings"])?.["non"])?.["existant"])?.["element"]; + const $if_let_value = $macros.__Json_tryGet(true, $macros.__Json_tryGet(true, $macros.__Json_tryGet(true, $macros.__Json_tryGet(false, jsonElements, "strings"), "non"), "existant"), "element"); if ($if_let_value != undefined) { const val = $if_let_value; $helpers.assert(false, "false"); } } { - const $if_let_value = (((jsonElements)?.["cant"])?.[1000])?.[42]; + const $if_let_value = $macros.__Json_tryGetAt(true, $macros.__Json_tryGetAt(true, $macros.__Json_tryGet(false, jsonElements, "cant"), 1000), 42); if ($if_let_value != undefined) { const val = $if_let_value; $helpers.assert(false, "false"); } } const notSpecified = ({"foo": "bar"}); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(notSpecified, "foo"), "bar"), "notSpecified.get(\"foo\") == \"bar\""); + $helpers.assert($helpers.eq($macros.__Json_get(false, notSpecified, "foo"), "bar"), "notSpecified.get(\"foo\") == \"bar\""); const empty = ({}); - $helpers.assert($helpers.eq(((obj, key) => { return obj.hasOwnProperty(key); })(empty,"something"), false), "empty.has(\"something\") == false"); + $helpers.assert($helpers.eq($macros.__Json_has(false, empty, "something"), false), "empty.has(\"something\") == false"); const arrayStruct = [({"foo": "", "stuff": []})]; const setStruct = new Set([({"foo": "", "stuff": []})]); const mapStruct = ({["1"]: ({"foo": "", "stuff": []})}); @@ -239,7 +241,7 @@ class $Root extends $stdlib.std.Resource { $helpers.assert($helpers.eq($helpers.lookup(punnedJson1, "numVar"), 1), "punnedJson1[\"numVar\"] == 1"); $helpers.assert($helpers.eq($helpers.lookup(punnedJson1, "strVar"), "s"), "punnedJson1[\"strVar\"] == \"s\""); const punnedMutJson1 = ({"numVar": numVar}); - ((obj, key, value) => { obj[key] = value; })(punnedMutJson1, "numVar", (((arg) => { if (typeof arg !== "number") {throw new Error("unable to parse " + typeof arg + " " + arg + " as a number")}; return JSON.parse(JSON.stringify(arg)) })($helpers.lookup(punnedMutJson1, "numVar")) + 1)); + $macros.__MutJson_set(false, punnedMutJson1, "numVar", ($macros.__MutJson_asNum(false, $helpers.lookup(punnedMutJson1, "numVar"), ) + 1)); $helpers.assert($helpers.eq($helpers.lookup(punnedMutJson1, "numVar"), 2), "punnedMutJson1[\"numVar\"] == 2"); const structToPunFromJson = ({"numVar": numVar, "strVar": strVar}); $helpers.assert($helpers.eq(structToPunFromJson.numVar, 1), "structToPunFromJson.numVar == 1"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md index 64dd15c8cf1..2750b98d799 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b, $fileName }) { class $Closure1 { constructor({ }) { @@ -13,7 +14,7 @@ module.exports = function({ $b, $fileName }) { } async handle() { const x = (await $b.getJson($fileName)); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error("Index out of bounds"); return obj[args] })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(x, "persons"), 0), "fears"), 1), "failure"), "x.get(\"persons\").getAt(0).get(\"fears\").getAt(1) == \"failure\""); + $helpers.assert($helpers.eq($macros.__Json_getAt(false, $macros.__Json_get(false, $macros.__Json_getAt(false, $macros.__Json_get(false, x, "persons"), 0), "fears"), 1), "failure"), "x.get(\"persons\").getAt(0).get(\"fears\").getAt(1) == \"failure\""); } } return $Closure1; @@ -25,6 +26,7 @@ module.exports = function({ $b, $fileName }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b, $fileName, $getJson, $j }) { class $Closure2 { constructor({ }) { @@ -184,6 +186,7 @@ module.exports = function({ $b, $fileName, $getJson, $j }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md index 50bd2a5ce78..ee615c190ba 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $jj, $std_Json }) { class $Closure1 { constructor({ }) { @@ -12,7 +13,7 @@ module.exports = function({ $jj, $std_Json }) { return $obj; } async handle() { - const ss = ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })($jj); + const ss = $macros.__Json_stringify(false, $std_Json, $jj); $helpers.assert($helpers.eq(ss, "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}"), "ss == \"\\{\\\"a\\\":123,\\\"b\\\":\\{\\\"c\\\":456,\\\"d\\\":789}}\""); } } @@ -25,6 +26,7 @@ module.exports = function({ $jj, $std_Json }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure2 { constructor({ }) { @@ -34,8 +36,8 @@ module.exports = function({ }) { } async handle() { const hasCheck = ({"a": "hello", "b": "wing"}); - $helpers.assert($helpers.eq(((obj, key) => { return obj.hasOwnProperty(key); })(hasCheck,"a"), true), "hasCheck.has(\"a\") == true"); - $helpers.assert($helpers.eq(((obj, key) => { return obj.hasOwnProperty(key); })(hasCheck,"c"), false), "hasCheck.has(\"c\") == false"); + $helpers.assert($helpers.eq($macros.__Json_has(false, hasCheck, "a"), true), "hasCheck.has(\"a\") == true"); + $helpers.assert($helpers.eq($macros.__Json_has(false, hasCheck, "c"), false), "hasCheck.has(\"c\") == false"); } } return $Closure2; @@ -65,6 +67,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -150,35 +153,35 @@ class $Root extends $stdlib.std.Resource { } } const x = ({"a": 123, "b": ({"c": 456, "d": 789})}); - const k = Object.keys(x); + const k = $macros.__Json_keys(false, std.Json, x); $helpers.assert($helpers.eq(k.length, 2), "k.length == 2"); - const v = Object.values(x); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(v, 0), 123), "v.at(0) == 123"); - const m = JSON.parse(JSON.stringify(x)); - ((obj, key, value) => { obj[key] = value; })(m, "a", 321); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(m, "a"), 321), "m.get(\"a\") == 321"); - const n = JSON.parse(JSON.stringify(m)); + const v = $macros.__Json_values(false, std.Json, x); + $helpers.assert($helpers.eq($macros.__Array_at(false, v, 0), 123), "v.at(0) == 123"); + const m = $macros.__Json_deepCopyMut(false, std.Json, x); + $macros.__MutJson_set(false, m, "a", 321); + $helpers.assert($helpers.eq($macros.__MutJson_get(false, m, "a"), 321), "m.get(\"a\") == 321"); + const n = $macros.__Json_deepCopy(false, std.Json, m); $helpers.assert($helpers.eq(m, n), "m == n"); - let k2 = Object.keys(m); + let k2 = $macros.__Json_keys(false, std.Json, m); $helpers.assert($helpers.eq(k2.length, 2), "k2.length == 2"); - ((json, key) => { delete json[key]; })(m, "b"); - k2 = Object.keys(m); + $macros.__Json_delete(false, std.Json, m, "b"); + k2 = $macros.__Json_keys(false, std.Json, m); $helpers.assert($helpers.eq(k2.length, 1), "k2.length == 1"); const s = "{\"a\": 123, \"b\": {\"c\": 456, \"d\": 789}}"; - const j = JSON.parse(s); - $helpers.assert($helpers.eq(Object.keys(j).length, 2), "Json.keys(j).length == 2"); + const j = $macros.__Json_parse(false, std.Json, s); + $helpers.assert($helpers.eq($macros.__Json_keys(false, std.Json, j).length, 2), "Json.keys(j).length == 2"); const invalidJson = "invalid"; - const tryParsed = (((args) => { try { return (args === undefined) ? undefined : JSON.parse(args); } catch (err) { return undefined; } })(invalidJson) ?? ({"key": "value"})); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(tryParsed, "key"), "value"), "tryParsed.get(\"key\") == \"value\""); + const tryParsed = ($macros.__Json_tryParse(false, std.Json, invalidJson) ?? ({"key": "value"})); + $helpers.assert($helpers.eq($macros.__Json_get(false, tryParsed, "key"), "value"), "tryParsed.get(\"key\") == \"value\""); const jj = ({"a": 123, "b": ({"c": 456, "d": 789})}); - const ss = ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(jj); + const ss = $macros.__Json_stringify(false, std.Json, jj); $helpers.assert($helpers.eq(ss, "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}"), "ss == \"\\{\\\"a\\\":123,\\\"b\\\":\\{\\\"c\\\":456,\\\"d\\\":789}}\""); - const ss2 = ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(jj, { indent: 2 }); + const ss2 = $macros.__Json_stringify(false, std.Json, jj, { indent: 2 }); $helpers.assert($helpers.eq(ss2, "{\n \"a\": 123,\n \"b\": {\n \"c\": 456,\n \"d\": 789\n }\n}"), "ss2 == \"\\{\\n \\\"a\\\": 123,\\n \\\"b\\\": \\{\\n \\\"c\\\": 456,\\n \\\"d\\\": 789\\n }\\n}\""); const jsonOfMany = ({"a": 123, "b": "hello", "c": true}); - $helpers.assert($helpers.eq((std.String.fromJson(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(jsonOfMany, "b"))), "hello"), "str.fromJson(jsonOfMany.get(\"b\")) == \"hello\""); - $helpers.assert($helpers.eq((std.Number.fromJson(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(jsonOfMany, "a"))), 123), "num.fromJson(jsonOfMany.get(\"a\")) == 123"); - $helpers.assert((std.Boolean.fromJson(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(jsonOfMany, "c"))), "bool.fromJson(jsonOfMany.get(\"c\"))"); + $helpers.assert($helpers.eq((std.String.fromJson($macros.__Json_get(false, jsonOfMany, "b"))), "hello"), "str.fromJson(jsonOfMany.get(\"b\")) == \"hello\""); + $helpers.assert($helpers.eq((std.Number.fromJson($macros.__Json_get(false, jsonOfMany, "a"))), 123), "num.fromJson(jsonOfMany.get(\"a\")) == 123"); + $helpers.assert((std.Boolean.fromJson($macros.__Json_get(false, jsonOfMany, "c"))), "bool.fromJson(jsonOfMany.get(\"c\"))"); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:Access Json static inflight", new $Closure1(this, "$Closure1")); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:has key or not", new $Closure2(this, "$Closure2")); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md index 5ebec84cfbf..e6b54294ca1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -36,14 +37,14 @@ class $Root extends $stdlib.std.Resource { let $preflightTypesMap = {}; $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const obj = ({"strValue": "test", "numValue": 1}); - const notStringifyStrValue = String.raw({ raw: ["string: ", ""] }, JSON.stringify(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"))); + const notStringifyStrValue = String.raw({ raw: ["string: ", ""] }, JSON.stringify($macros.__Json_get(false, obj, "strValue"))); $helpers.assert($helpers.eq(notStringifyStrValue, "string: \"test\""), "notStringifyStrValue == \"string: \\\"test\\\"\""); - const stringifyNumValue = String.raw({ raw: ["number: ", ""] }, JSON.stringify(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "numValue"))); + const stringifyNumValue = String.raw({ raw: ["number: ", ""] }, JSON.stringify($macros.__Json_get(false, obj, "numValue"))); $helpers.assert($helpers.eq(stringifyNumValue, "number: 1"), "stringifyNumValue == \"number: 1\""); - $helpers.assert($helpers.eq(String.raw({ raw: ["", ""] }, JSON.stringify(obj)), ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(obj)), "\"{obj}\" == Json.stringify(obj)"); - $helpers.assert($helpers.eq(String.raw({ raw: ["", ""] }, JSON.stringify(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"))), ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"))), "\"{obj.get(\"strValue\")}\" == Json.stringify(obj.get(\"strValue\"))"); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"), JSON.parse(((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue")))), "obj.get(\"strValue\") == Json.parse(Json.stringify(obj.get(\"strValue\")))"); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"), JSON.parse(String.raw({ raw: ["", ""] }, JSON.stringify(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"))))), "obj.get(\"strValue\") == Json.parse(\"{obj.get(\"strValue\")}\")"); + $helpers.assert($helpers.eq(String.raw({ raw: ["", ""] }, JSON.stringify(obj)), $macros.__Json_stringify(false, std.Json, obj)), "\"{obj}\" == Json.stringify(obj)"); + $helpers.assert($helpers.eq(String.raw({ raw: ["", ""] }, JSON.stringify($macros.__Json_get(false, obj, "strValue"))), $macros.__Json_stringify(false, std.Json, $macros.__Json_get(false, obj, "strValue"))), "\"{obj.get(\"strValue\")}\" == Json.stringify(obj.get(\"strValue\"))"); + $helpers.assert($helpers.eq($macros.__Json_get(false, obj, "strValue"), $macros.__Json_parse(false, std.Json, $macros.__Json_stringify(false, std.Json, $macros.__Json_get(false, obj, "strValue")))), "obj.get(\"strValue\") == Json.parse(Json.stringify(obj.get(\"strValue\")))"); + $helpers.assert($helpers.eq($macros.__Json_get(false, obj, "strValue"), $macros.__Json_parse(false, std.Json, String.raw({ raw: ["", ""] }, JSON.stringify($macros.__Json_get(false, obj, "strValue"))))), "obj.get(\"strValue\") == Json.parse(\"{obj.get(\"strValue\")}\")"); } } const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "json_string_interpolation.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md index ef37e1c6450..e4700fb37f4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ $foo_this_value }) { @@ -25,6 +26,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -57,6 +59,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md index a0f685d04a7..89cc694e121 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b1 }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $b1 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f4 }) { class $Closure10 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $f4 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b2 }) { class $Closure2 { constructor({ }) { @@ -64,6 +67,7 @@ module.exports = function({ $b2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $ar }) { class $Closure3 { constructor({ }) { @@ -86,6 +90,7 @@ module.exports = function({ $ar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f1 }) { class $Closure4 { constructor({ }) { @@ -106,6 +111,7 @@ module.exports = function({ $f1 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $map }) { class $Closure5 { constructor({ }) { @@ -114,7 +120,7 @@ module.exports = function({ $map }) { return $obj; } async handle() { - for (const c of Object.values($map)) { + for (const c of $macros.__Map_values(false, $map, )) { (await c()); } } @@ -128,6 +134,7 @@ module.exports = function({ $map }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f2 }) { class $Closure6 { constructor({ }) { @@ -148,6 +155,7 @@ module.exports = function({ $f2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $set }) { class $Closure7 { constructor({ }) { @@ -170,6 +178,7 @@ module.exports = function({ $set }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f3 }) { class $Closure8 { constructor({ }) { @@ -190,6 +199,7 @@ module.exports = function({ $f3 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $complex }) { class $Closure9 { constructor({ }) { @@ -200,7 +210,7 @@ module.exports = function({ $complex }) { async handle() { const i = 0; const k = "k1"; - for (const c of ((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($complex, i), k)) { + for (const c of $macros.__Map_get(false, $macros.__Array_at(false, $complex, i), k)) { (await c()); } } @@ -643,6 +653,7 @@ module.exports = function({ $complex }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md index e420df1e382..a892ebf442d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $Foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure3 { constructor({ }) { @@ -64,6 +67,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b, $bar }) { class $Closure4 { constructor({ }) { @@ -87,6 +91,7 @@ module.exports = function({ $b, $bar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { async do() { @@ -134,6 +139,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md index 40e942ec40e..4fcf075f67c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $c }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $c }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ $this_a }) { @@ -42,6 +44,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class B extends $A { constructor({ $this_b, $this_a }) { @@ -61,6 +64,7 @@ module.exports = function({ $A }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $B }) { class C extends $B { constructor({ $this_b, $this_c, $this_a }) { @@ -102,6 +106,7 @@ module.exports = function({ $B }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md index 221e1cdde4e..6e3222aa86c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $y }) { class $Closure1 { constructor({ }) { @@ -44,6 +45,7 @@ module.exports = function({ $y }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md index 97e6af45332..a3139657861 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b1, $b2 }) { class $Closure1 { constructor({ }) { @@ -26,6 +27,7 @@ module.exports = function({ $b1, $b2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $http_Util }) { class $Closure2 { constructor({ }) { @@ -47,6 +49,7 @@ module.exports = function({ $api_url, $http_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyBucket { constructor({ $this_bucket }) { @@ -302,6 +305,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md index 7ca22c5ae6b..eb608ef5baa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f, $util_Util }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $f, $util_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -66,6 +68,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -85,7 +88,7 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); } onLift(host, ops) { - if (ops.includes("bar")) { + if ($macros.__Array_contains(false, ops, "bar")) { (host.addEnvironment("BAR", "123")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md index eb013c13f9e..bd89e067ef7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket2 }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $bucket2 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $fn }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket2, $fn2, $fn2_bucket }) { class $Closure3 { constructor({ }) { @@ -67,6 +70,7 @@ module.exports = function({ $bucket2, $fn2, $fn2_bucket }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket2 }) { class MyClosure { constructor({ $this_bucket }) { @@ -139,6 +143,7 @@ module.exports = function({ $bucket2 }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md index b4dce14b238..ac455f40b46 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $fn }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyClosure { constructor({ $this_q }) { @@ -78,6 +80,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md index 0e7795943ef..67b809605ad 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b, $c }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $b, $c }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class B { constructor({ }) { @@ -41,6 +43,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class C { constructor({ $this_b }) { @@ -77,6 +80,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md index dc2e4805cc5..5f167c25bd0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $ar, $math_Util }) { class $Closure1 { constructor({ }) { @@ -12,14 +13,14 @@ module.exports = function({ $ar, $math_Util }) { return $obj; } async handle() { - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($ar, 0), 1), "ar.at(0) == 1"); + $helpers.assert($helpers.eq($macros.__Array_at(false, $ar, 0), 1), "ar.at(0) == 1"); const i = (await $math_Util.floor(((await $math_Util.random()) * $ar.length))); - let x = ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($ar, i); + let x = $macros.__Array_at(false, $ar, i); $helpers.assert(((x >= 1) && (x <= 3)), "x >= 1 && x <= 3"); - x = ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($ar, ((1 - 1) + i)); + x = $macros.__Array_at(false, $ar, ((1 - 1) + i)); $helpers.assert(((x >= 1) && (x <= 3)), "x >= 1 && x <= 3"); - const mut_ar = [...($ar)]; - mut_ar.push(4); + const mut_ar = $macros.__Array_copyMut(false, $ar, ); + $macros.__MutArray_push(false, mut_ar, 4); } } return $Closure1; @@ -49,6 +50,7 @@ module.exports = function({ $ar, $math_Util }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md index 3ac25a042ab..a22bf17a78f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $map }) { class $Closure1 { constructor({ }) { @@ -12,9 +13,9 @@ module.exports = function({ $map }) { return $obj; } async handle() { - $helpers.assert($helpers.eq(Object.keys($map).length, 1), "map.size() == 1"); - $helpers.assert(("foo" in ($map)), "map.has(\"foo\")"); - $helpers.assert((!("bar" in ($map))), "!map.has(\"bar\")"); + $helpers.assert($helpers.eq($macros.__Map_size(false, $map, ), 1), "map.size() == 1"); + $helpers.assert($macros.__Map_has(false, $map, "foo"), "map.has(\"foo\")"); + $helpers.assert((!$macros.__Map_has(false, $map, "bar")), "!map.has(\"bar\")"); } } return $Closure1; @@ -26,6 +27,7 @@ module.exports = function({ $map }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $map }) { class $Closure2 { constructor({ }) { @@ -34,7 +36,7 @@ module.exports = function({ $map }) { return $obj; } async handle() { - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })($map, "foo"), "hello"), "map.get(\"foo\") == \"hello\""); + $helpers.assert($helpers.eq($macros.__Map_get(false, $map, "foo"), "hello"), "map.get(\"foo\") == \"hello\""); } } return $Closure2; @@ -46,6 +48,7 @@ module.exports = function({ $map }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $map }) { class $Closure3 { constructor({ }) { @@ -54,8 +57,8 @@ module.exports = function({ $map }) { return $obj; } async handle() { - const entries = Object.entries($map).map(([key, value]) => ({ key, value })); - for (const x of Object.entries($map).map(([key, value]) => ({ key, value }))) { + const entries = $macros.__Map_entries(false, $map, ); + for (const x of $macros.__Map_entries(false, $map, )) { $helpers.assert($helpers.eq(x.key, "foo"), "x.key == \"foo\""); $helpers.assert($helpers.eq(x.value, "hello"), "x.value == \"hello\""); } @@ -70,6 +73,7 @@ module.exports = function({ $map }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure4 { constructor({ }) { @@ -79,7 +83,7 @@ module.exports = function({ }) { } async handle() { const map = ({["foo"]: "hello", ["bar"]: "world"}); - $helpers.assert($helpers.eq(Object.entries(map).map(([key, value]) => ({ key, value })).length, 2), "map.entries().length == 2"); + $helpers.assert($helpers.eq($macros.__Map_entries(false, map, ).length, 2), "map.entries().length == 2"); } } return $Closure4; @@ -109,6 +113,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md index ce9c8468738..738e46ba87d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md @@ -56,6 +56,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -77,12 +78,12 @@ class $Root extends $stdlib.std.Resource { const arr2 = [1, 2, 3]; const arr3 = [bucket1, bucket2]; const arr4 = arr1; - arr1.push("a"); - arr2.push(4); - arr3.push(bucket3); + $macros.__MutArray_push(false, arr1, "a"); + $macros.__MutArray_push(false, arr2, 4); + $macros.__MutArray_push(false, arr3, bucket3); $helpers.assert($helpers.eq((arr2.pop()), 4), "arr2.pop() == 4"); $helpers.assert($helpers.eq(arr1.length, 4), "arr1.length == 4"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(arr4, 0), "a"), "arr4.at(0) == \"a\""); + $helpers.assert($helpers.eq($macros.__MutArray_at(false, arr4, 0), "a"), "arr4.at(0) == \"a\""); const s1 = new Set([1, 2, 3, 3]); const s2 = new Set(["hello", "world", "hello"]); const s3 = new Set([bucket1, bucket2, bucket2]); @@ -98,17 +99,17 @@ class $Root extends $stdlib.std.Resource { const m4 = m1; const m5 = ({["goodbye"]: "world"}); const m6 = ({["a"]: m1, ["b"]: m5}); - $helpers.assert(("hello" in (m1)), "m1.has(\"hello\")"); - $helpers.assert($helpers.eq(Object.keys(m2).length, 1), "m2.size() == 1"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`MutMap does not contain key: "${key}"`); return obj[key]; })(m3, "b1"), bucket1), "m3.get(\"b1\") == bucket1"); - $helpers.assert($helpers.eq(Object.keys(m4).length, 1), "m4.size() == 1"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`MutMap does not contain key: "${key}"`); return obj[key]; })(((obj, key) => { if (!(key in obj)) throw new Error(`MutMap does not contain key: "${key}"`); return obj[key]; })(m6, "a"), "hello"), "world"), "m6.get(\"a\").get(\"hello\") == \"world\""); - ((obj, args) => { obj[args[0]] = args[1]; })(m1, ["hello", "goodbye"]); - ((obj, args) => { obj[args[0]] = args[1]; })(m6, ["a", ({["foo"]: "bar"})]); - ((map) => { for(const k in map){delete map[k]}; })(m2); - $helpers.assert($helpers.eq(Object.keys(m2).length, 0), "m2.size() == 0"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`MutMap does not contain key: "${key}"`); return obj[key]; })(m1, "hello"), "goodbye"), "m1.get(\"hello\") == \"goodbye\""); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`MutMap does not contain key: "${key}"`); return obj[key]; })(((obj, key) => { if (!(key in obj)) throw new Error(`MutMap does not contain key: "${key}"`); return obj[key]; })(m6, "a"), "foo"), "bar"), "m6.get(\"a\").get(\"foo\") == \"bar\""); + $helpers.assert($macros.__MutMap_has(false, m1, "hello"), "m1.has(\"hello\")"); + $helpers.assert($helpers.eq($macros.__MutMap_size(false, m2, ), 1), "m2.size() == 1"); + $helpers.assert($helpers.eq($macros.__MutMap_get(false, m3, "b1"), bucket1), "m3.get(\"b1\") == bucket1"); + $helpers.assert($helpers.eq($macros.__MutMap_size(false, m4, ), 1), "m4.size() == 1"); + $helpers.assert($helpers.eq($macros.__MutMap_get(false, $macros.__MutMap_get(false, m6, "a"), "hello"), "world"), "m6.get(\"a\").get(\"hello\") == \"world\""); + $macros.__MutMap_set(false, m1, "hello", "goodbye"); + $macros.__MutMap_set(false, m6, "a", ({["foo"]: "bar"})); + $macros.__MutMap_clear(false, m2, ); + $helpers.assert($helpers.eq($macros.__MutMap_size(false, m2, ), 0), "m2.size() == 0"); + $helpers.assert($helpers.eq($macros.__MutMap_get(false, m1, "hello"), "goodbye"), "m1.get(\"hello\") == \"goodbye\""); + $helpers.assert($helpers.eq($macros.__MutMap_get(false, $macros.__MutMap_get(false, m6, "a"), "foo"), "bar"), "m6.get(\"a\").get(\"foo\") == \"bar\""); } } const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "mut_container_types.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md index abdf41ca7a4..c0dc1bb3357 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_2_consumer }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $__parent_this_2_consumer }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $c }) { class $Closure3 { constructor({ }) { @@ -65,6 +68,7 @@ module.exports = function({ $c }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $c, $q, $util_Util }) { class $Closure4 { constructor({ }) { @@ -88,6 +92,7 @@ module.exports = function({ $c, $q, $util_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Queue { constructor({ $this_data }) { @@ -336,6 +341,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/namspaced-expr-in-index-expr.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/namspaced-expr-in-index-expr.test.w_compile_tf-aws.md index c9f4752a2d2..f2bda21bd1c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/namspaced-expr-in-index-expr.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/namspaced-expr-in-index-expr.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md index b5127b1f533..349071dc85e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket, $bucket3 }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $bucket, $bucket3 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -39,6 +41,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $FooParent }) { class Foo extends $FooParent { constructor({ }) { @@ -54,6 +57,7 @@ module.exports = function({ $FooParent }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class FooParent { constructor({ }) { @@ -68,6 +72,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class LibClass { constructor({ }) { @@ -82,6 +87,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyClass { constructor({ }) { @@ -168,6 +174,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -358,6 +365,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md index 9905f1aa986..e67d6096c87 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class LibClass { constructor({ }) { @@ -32,6 +34,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md index be35c2102e0..55636046302 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class CustomScope { constructor({ }) { @@ -50,6 +51,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md index 3e11bc927ee..7e9b91334cf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $foo }) { class $Closure2 { constructor({ }) { @@ -49,6 +51,7 @@ module.exports = function({ $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -96,6 +99,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md index 20f8d352fc8..2fc200e596e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo, $foo }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $Foo, $foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $util_Util }) { class Foo { constructor({ }) { @@ -65,6 +67,7 @@ module.exports = function({ $util_Util }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -84,12 +87,12 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); } onLift(host, ops) { - if (ops.includes("m1")) { + if ($macros.__Array_contains(false, ops, "m1")) { (host.addEnvironment("ABC", "123")); } } static onLiftType(host, ops) { - if (ops.includes("m2")) { + if ($macros.__Array_contains(false, ops, "m2")) { (host.addEnvironment("XYZ", "789")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/optional_macros.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/optional_macros.test.w_compile_tf-aws.md new file mode 100644 index 00000000000..d08ff68b277 --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/valid/optional_macros.test.w_compile_tf-aws.md @@ -0,0 +1,146 @@ +# [optional_macros.test.w](../../../../../examples/tests/valid/optional_macros.test.w) | compile | tf-aws + +## inflight.$Closure1-1.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); +module.exports = function({ $expect_Util }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const result = ({}); + (await $expect_Util.equal($macros.__Json_tryGet(true, result.item, "id"), undefined)); + (await $expect_Util.equal($macros.__Json_has(true, result.item, "id"), undefined)); + (await $expect_Util.equal($macros.__Json_tryGet(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (await $expect_Util.equal($macros.__Json_has(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (await $expect_Util.equal($macros.__Map_tryGet(true, result.mapItem, "a"), undefined)); + (await $expect_Util.equal($macros.__Map_has(true, result.mapItem, "id"), undefined)); + (await $expect_Util.equal($macros.__Map_tryGet(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (await $expect_Util.equal($macros.__Map_has(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (await $expect_Util.equal(result.setItem?.size, undefined)); + (await $expect_Util.equal((await result.setItem?.has?.(6)), undefined)); + (await $expect_Util.equal($macros.__Array_tryAt(true, result.setItems, 0)?.size, undefined)); + (await $expect_Util.equal((await $macros.__Array_tryAt(true, result.setItems, 0)?.has?.(6)), undefined)); + (await $expect_Util.equal(result.structItem?.item, undefined)); + (await $expect_Util.equal($macros.__Array_tryAt(true, result.structItems, 0)?.item, undefined)); + let calls = 0; + const makeArray = (async () => { + calls = (calls + 1); + return [1, 2, 3]; + }); + (await $expect_Util.ok(($macros.__Array_contains(true, (await makeArray()), 2) ?? false))); + (await $expect_Util.equal(calls, 1)); + } + } + return $Closure1; +} +//# sourceMappingURL=inflight.$Closure1-1.cjs.map +``` + +## main.tf.json +```json +{ + "//": { + "metadata": { + "backend": "local", + "stackName": "root" + }, + "outputs": {} + }, + "provider": { + "aws": [ + {} + ] + } +} +``` + +## preflight.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); +const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); +const $outdir = process.env.WING_SYNTH_DIR ?? "."; +const $wing_is_test = process.env.WING_IS_TEST === "true"; +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); +class $Root extends $stdlib.std.Resource { + constructor($scope, $id) { + super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; + class $Closure1 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ + $expect_Util: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"))}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType()}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["ok"])], + ], + "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + ], + }); + } + } + const result = ({}); + (expect.Util.equal($macros.__Json_tryGet(true, result.item, "id"), undefined)); + (expect.Util.equal($macros.__Json_has(true, result.item, "id"), undefined)); + (expect.Util.equal($macros.__Json_tryGet(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (expect.Util.equal($macros.__Json_has(true, $macros.__Array_tryAt(true, result.items, 0), "id"), undefined)); + (expect.Util.equal($macros.__Map_tryGet(true, result.mapItem, "a"), undefined)); + (expect.Util.equal($macros.__Map_has(true, result.mapItem, "id"), undefined)); + (expect.Util.equal($macros.__Map_tryGet(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (expect.Util.equal($macros.__Map_has(true, $macros.__Array_tryAt(true, result.mapItems, 0), "id"), undefined)); + (expect.Util.equal(result.setItem?.size, undefined)); + (expect.Util.equal((result.setItem?.has?.(6)), undefined)); + (expect.Util.equal($macros.__Array_tryAt(true, result.setItems, 0)?.size, undefined)); + (expect.Util.equal(($macros.__Array_tryAt(true, result.setItems, 0)?.has?.(6)), undefined)); + (expect.Util.equal(result.structItem?.item, undefined)); + (expect.Util.equal($macros.__Array_tryAt(true, result.structItems, 0)?.item, undefined)); + let calls = 0; + const makeArray = (() => { + calls = (calls + 1); + return [1, 2, 3]; + }); + (expect.Util.ok(($macros.__Array_contains(true, (makeArray()), 2) ?? false))); + (expect.Util.equal(calls, 1)); + globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:optional chaining macros", new $Closure1(this, "$Closure1")); + } +} +const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "optional_macros.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); +$APP.synth(); +//# sourceMappingURL=preflight.cjs.map +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/optional_macros.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/optional_macros.test.w_test_sim.md new file mode 100644 index 00000000000..0747ea997ed --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/valid/optional_macros.test.w_test_sim.md @@ -0,0 +1,12 @@ +# [optional_macros.test.w](../../../../../examples/tests/valid/optional_macros.test.w) | test | sim + +## stdout.log +```log +pass ─ optional_macros.test.wsim » root/env0/test:optional chaining macros + +Tests 1 passed (1) +Snapshots 1 skipped +Test Files 1 passed (1) +Duration +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md index 5c0dc2bcc7d..a01cd352cde 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $payloadWithBucket_c, $payloadWithoutOptions_b }) { class $Closure1 { constructor({ }) { @@ -27,6 +28,7 @@ module.exports = function({ $payloadWithBucket_c, $payloadWithoutOptions_b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Node { constructor({ }) { @@ -41,6 +43,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Super }) { class Sub extends $Super { constructor({ }) { @@ -56,6 +59,7 @@ module.exports = function({ $Super }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Sub }) { class SubSub extends $Sub { constructor({ }) { @@ -71,6 +75,7 @@ module.exports = function({ $Sub }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Super { constructor({ }) { @@ -117,6 +122,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -323,24 +329,24 @@ class $Root extends $stdlib.std.Resource { if ((parts.length < 1)) { return undefined; } - return ({"first": (parts.at(0) ?? ""), "last": (parts.at(1) ?? "")}); + return ({"first": ($macros.__Array_tryAt(false, parts, 0) ?? ""), "last": ($macros.__Array_tryAt(false, parts, 1) ?? "")}); }); const json_obj = ({"ghost": "spooky"}); let something_else = false; { - const $if_let_value = ((arg) => { return (typeof arg === "boolean") ? JSON.parse(JSON.stringify(arg)) : undefined })(json_obj); + const $if_let_value = $macros.__Json_tryAsBool(false, json_obj, ); if ($if_let_value != undefined) { const y = $if_let_value; $helpers.assert(($helpers.eq(y, true) || $helpers.eq(y, false)), "y == true || y == false"); } else { - const $elif_let_value0 = ((arg) => { return (typeof arg === "number") ? JSON.parse(JSON.stringify(arg)) : undefined })(json_obj); + const $elif_let_value0 = $macros.__Json_tryAsNum(false, json_obj, ); if ($elif_let_value0 != undefined) { const y = $elif_let_value0; $helpers.assert($helpers.eq((y + 0), y), "y + 0 == y"); } else { - const $elif_let_value1 = ((arg) => { return (typeof arg === "string") ? JSON.parse(JSON.stringify(arg)) : undefined })(json_obj); + const $elif_let_value1 = $macros.__Json_tryAsStr(false, json_obj, ); if ($elif_let_value1 != undefined) { const y = $elif_let_value1; $helpers.assert((y.length >= 0), "y.length >= 0"); @@ -527,7 +533,7 @@ class $Root extends $stdlib.std.Resource { $helpers.assert($helpers.eq($helpers.unwrap((maybeFn(true))), ["hi"]), "maybeFn(true)! == [\"hi\"]"); const maybeVarBool = true; $helpers.assert($helpers.eq((!$helpers.unwrap(maybeVarBool)), false), "!maybeVarBool! == false"); - const person = $helpers.unwrap(Person._tryParseJson(((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"name": "john", "age": 30})))); + const person = $helpers.unwrap($macros.__Struct_tryParseJson(false, Person, $macros.__Json_stringify(false, std.Json, ({"name": "john", "age": 30})))); $helpers.assert(($helpers.eq(person.name, "john") && $helpers.eq(person.age, 30)), "person.name == \"john\" && person.age == 30"); const maybeX = 0; $helpers.assert($helpers.eq($helpers.unwrap(maybeX), 0), "maybeX! == 0"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md index 0ec6ec99085..52d78b5939e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -37,10 +38,10 @@ class $Root extends $stdlib.std.Resource { const MyParams = $stdlib.std.Struct._createJsonSchema({$id:"/MyParams",type:"object",properties:{houses:{type:"array",items:{type:"object",properties:{address:{type:"string"},residents:{type:"array",items:{type:"object",properties:{age:{type:"number"},name:{type:"string"},},required:["age","name",]}},},required:["address","residents",]}},},required:["houses",]}); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = $helpers.nodeof(this).app; - const myParams = MyParams._fromJson((app.parameters.read({ schema: MyParams }))); + const myParams = $macros.__Struct_fromJson(false, MyParams, (app.parameters.read({ schema: $macros.__Struct_schema(false, MyParams, ) }))); $helpers.assert($helpers.eq(myParams.houses.length, 2), "myParams.houses.length == 2"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(myParams.houses, 0).address, "123 Main St"), "myParams.houses.at(0).address == \"123 Main St\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(myParams.houses, 0).residents.length, 2), "myParams.houses.at(0).residents.length == 2"); + $helpers.assert($helpers.eq($macros.__Array_at(false, myParams.houses, 0).address, "123 Main St"), "myParams.houses.at(0).address == \"123 Main St\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, myParams.houses, 0).residents.length, 2), "myParams.houses.at(0).residents.length == 2"); } } const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "parameters.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md index 6f77e5b69a5..cb783d6032f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -37,7 +38,7 @@ class $Root extends $stdlib.std.Resource { const MyParams = $stdlib.std.Struct._createJsonSchema({$id:"/MyParams",type:"object",properties:{foo:{type:"string"},meaningOfLife:{type:"number"},},required:["meaningOfLife",]}); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = $helpers.nodeof(this).app; - const myParams = MyParams._fromJson((app.parameters.read({ schema: MyParams }))); + const myParams = $macros.__Struct_fromJson(false, MyParams, (app.parameters.read({ schema: $macros.__Struct_schema(false, MyParams, ) }))); { const $if_let_value = myParams.foo; if ($if_let_value != undefined) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md index 4c8a227b467..e394b457673 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $expect_Util, $tokenLength, $urlRegex }) { class $Closure1 { constructor({ }) { @@ -13,7 +14,7 @@ module.exports = function({ $api_url, $expect_Util, $tokenLength, $urlRegex }) { } async handle() { (await $expect_Util.equal((await $urlRegex.test($api_url)), true)); - (await $expect_Util.equal($api_url.startsWith("http"), true)); + (await $expect_Util.equal($macros.__String_startsWith(false, $api_url, "http"), true)); (await $expect_Util.notEqual($api_url.length, $tokenLength)); } } @@ -130,6 +131,7 @@ module.exports = function({ $api_url, $expect_Util, $tokenLength, $urlRegex }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md index 8b13309e561..f9fa50909b6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -41,10 +42,10 @@ class $Root extends $stdlib.std.Resource { }); const stringy = String.raw({ raw: ["", ":", ""] }, dur.minutes, dur.seconds); console.log(stringy); - if ((stringy.includes("60") && $helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })((stringy.split(":")), 0), "60"))) { + if (($macros.__String_contains(false, stringy, "60") && $helpers.eq($macros.__Array_at(false, (stringy.split(":")), 0), "60"))) { console.log(String.raw({ raw: ["", "!"] }, stringy.length)); } - $helpers.assert($helpers.eq(((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return Number(args) })("123"), 123), "num.fromStr(\"123\") == 123"); + $helpers.assert($helpers.eq($macros.__Number_fromStr(false, std.Number, "123"), 123), "num.fromStr(\"123\") == 123"); } } const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "primitive_methods.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md index dd504af76ec..15b5b7a4198 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure2 { constructor({ }) { @@ -64,6 +66,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md index 73a03eda6fc..1cd63094584 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class R { constructor({ }) { @@ -36,6 +37,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md index 75c2d3b34e7..b3bb19e28a5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bucket, $res, $res_foo }) { class $Closure1 { constructor({ }) { @@ -29,6 +30,7 @@ module.exports = function({ $bucket, $res, $res_foo }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_2_b }) { class $Closure2 { constructor({ }) { @@ -49,6 +51,7 @@ module.exports = function({ $__parent_this_2_b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_3_b }) { class $Closure3 { constructor({ }) { @@ -69,6 +72,7 @@ module.exports = function({ $__parent_this_3_b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_4_q }) { class $Closure4 { constructor({ }) { @@ -89,6 +93,7 @@ module.exports = function({ $__parent_this_4_q }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bigOlPublisher, $util_Util }) { class $Closure5 { constructor({ }) { @@ -114,6 +119,7 @@ module.exports = function({ $bigOlPublisher, $util_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Foo, $MyEnum }) { class Bar { constructor({ $this_b, $this_e, $this_foo }) { @@ -147,6 +153,7 @@ module.exports = function({ $Foo, $MyEnum }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class BigPublisher { constructor({ $this_b, $this_b2, $this_q, $this_t }) { @@ -173,6 +180,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Dummy { constructor({ }) { @@ -187,6 +195,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ $this_c }) { @@ -216,6 +225,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class ScopeAndIdTestClass { constructor({ }) { @@ -711,6 +721,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -1112,15 +1123,15 @@ class $Root extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); const d1 = new Dummy(this, "Dummy"); - $helpers.assert($helpers.nodeof(d1).path.endsWith("/ScopeAndIdTestClass/Dummy"), "nodeof(d1).path.endsWith(\"/ScopeAndIdTestClass/Dummy\")"); + $helpers.assert($macros.__String_endsWith(false, $helpers.nodeof(d1).path, "/ScopeAndIdTestClass/Dummy"), "nodeof(d1).path.endsWith(\"/ScopeAndIdTestClass/Dummy\")"); const d2 = new Dummy(d1, "Dummy"); - $helpers.assert($helpers.nodeof(d2).path.endsWith("/ScopeAndIdTestClass/Dummy/Dummy"), "nodeof(d2).path.endsWith(\"/ScopeAndIdTestClass/Dummy/Dummy\")"); + $helpers.assert($macros.__String_endsWith(false, $helpers.nodeof(d2).path, "/ScopeAndIdTestClass/Dummy/Dummy"), "nodeof(d2).path.endsWith(\"/ScopeAndIdTestClass/Dummy/Dummy\")"); const d3 = new Dummy((Dummy.getInstance(this, d2)), "Dummy"); - $helpers.assert($helpers.nodeof(d3).path.endsWith("/ScopeAndIdTestClass/Dummy/Dummy/StaticDummy/Dummy"), "nodeof(d3).path.endsWith(\"/ScopeAndIdTestClass/Dummy/Dummy/StaticDummy/Dummy\")"); + $helpers.assert($macros.__String_endsWith(false, $helpers.nodeof(d3).path, "/ScopeAndIdTestClass/Dummy/Dummy/StaticDummy/Dummy"), "nodeof(d3).path.endsWith(\"/ScopeAndIdTestClass/Dummy/Dummy/StaticDummy/Dummy\")"); for (const i of $helpers.range(0,3,false)) { const x = new Dummy(this, String.raw({ raw: ["tc", ""] }, i)); const expected_path = String.raw({ raw: ["/ScopeAndIdTestClass/tc", ""] }, i); - $helpers.assert($helpers.nodeof(x).path.endsWith(expected_path), "nodeof(x).path.endsWith(expected_path)"); + $helpers.assert($macros.__String_endsWith(false, $helpers.nodeof(x).path, expected_path), "nodeof(x).path.endsWith(expected_path)"); } } static _toInflightType() { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md index 5a9fcc93933..165f2a81845 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $fn }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -171,6 +173,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md index d580cfe9038..7b3688d3fc8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Another }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $Another }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $globalCounter }) { class Another { constructor({ }) { @@ -80,6 +82,7 @@ module.exports = function({ $globalCounter }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md index dd8f50a3270..a73dc06811e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $r }) { class $Closure1 { constructor({ }) { @@ -34,6 +35,7 @@ module.exports = function({ $r }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Another { constructor({ }) { @@ -54,6 +56,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class First { constructor({ }) { @@ -68,6 +71,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class MyResource { constructor({ $this_another, $this_another_first_myResource, $this_another_myField, $this_arrayOfStr, $this_extBucket, $this_extNum, $this_mapOfNum, $this_myBool, $this_myNum, $this_myOptStr, $this_myQueue, $this_myResource, $this_myStr, $this_setOfStr }) { @@ -93,10 +97,10 @@ module.exports = function({ }) { } async testCaptureCollectionsOfData() { $helpers.assert($helpers.eq(this.$this_arrayOfStr.length, 2), "this.arrayOfStr.length == 2"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(this.$this_arrayOfStr, 0), "s1"), "this.arrayOfStr.at(0) == \"s1\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(this.$this_arrayOfStr, 1), "s2"), "this.arrayOfStr.at(1) == \"s2\""); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(this.$this_mapOfNum, "k1"), 11), "this.mapOfNum.get(\"k1\") == 11"); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(this.$this_mapOfNum, "k2"), 22), "this.mapOfNum.get(\"k2\") == 22"); + $helpers.assert($helpers.eq($macros.__Array_at(false, this.$this_arrayOfStr, 0), "s1"), "this.arrayOfStr.at(0) == \"s1\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, this.$this_arrayOfStr, 1), "s2"), "this.arrayOfStr.at(1) == \"s2\""); + $helpers.assert($helpers.eq($macros.__Map_get(false, this.$this_mapOfNum, "k1"), 11), "this.mapOfNum.get(\"k1\") == 11"); + $helpers.assert($helpers.eq($macros.__Map_get(false, this.$this_mapOfNum, "k2"), 22), "this.mapOfNum.get(\"k2\") == 22"); $helpers.assert((await this.$this_setOfStr.has("s1")), "this.setOfStr.has(\"s1\")"); $helpers.assert((await this.$this_setOfStr.has("s2")), "this.setOfStr.has(\"s2\")"); $helpers.assert((!(await this.$this_setOfStr.has("s3"))), "!this.setOfStr.has(\"s3\")"); @@ -234,6 +238,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md index a3bec0cf33b..a84fe167f48 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $res }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $res }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Another }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $Another }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $globalCounter }) { class Another { constructor({ }) { @@ -68,6 +71,7 @@ module.exports = function({ $globalCounter }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class First { constructor({ }) { @@ -82,6 +86,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Another, $globalAnother, $globalAnother_first_myResource, $globalAnother_myField, $globalArrayOfStr, $globalBool, $globalBucket, $globalMapOfNum, $globalNum, $globalSetOfStr, $globalStr, $util_Util }) { class MyResource { constructor({ $this_localCounter, $this_localTopic }) { @@ -94,8 +99,8 @@ module.exports = function({ $Another, $globalAnother, $globalAnother_first_myRes $helpers.assert($helpers.eq($globalStr, "hello"), "globalStr == \"hello\""); $helpers.assert($helpers.eq($globalBool, true), "globalBool == true"); $helpers.assert($helpers.eq($globalNum, 42), "globalNum == 42"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })($globalArrayOfStr, 0), "hello"), "globalArrayOfStr.at(0) == \"hello\""); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })($globalMapOfNum, "a"), (-5)), "globalMapOfNum.get(\"a\") == -5"); + $helpers.assert($helpers.eq($macros.__Array_at(false, $globalArrayOfStr, 0), "hello"), "globalArrayOfStr.at(0) == \"hello\""); + $helpers.assert($helpers.eq($macros.__Map_get(false, $globalMapOfNum, "a"), (-5)), "globalMapOfNum.get(\"a\") == -5"); $helpers.assert((await $globalSetOfStr.has("a")), "globalSetOfStr.has(\"a\")"); $helpers.assert($helpers.eq($globalAnother_myField, "hello!"), "globalAnother.myField == \"hello!\""); (await $globalAnother_first_myResource.put("key", "value")); @@ -115,6 +120,7 @@ module.exports = function({ $Another, $globalAnother, $globalAnother_first_myRes ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $_parentThis_localCounter, $globalCounter }) { class R { constructor({ }) { @@ -359,6 +365,7 @@ module.exports = function({ $_parentThis_localCounter, $globalCounter }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/rootid.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/rootid.test.w_compile_tf-aws.md index 5b451d859c1..fd592bb6152 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/rootid.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/rootid.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $envRootId, $expect_Util, $rootId }) { class $Closure1 { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ $envRootId, $expect_Util, $rootId }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md index fb01bc297cb..9393c6796b3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md index 626adb75a84..bc176df48f1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bar }) { class $Closure1 { constructor({ }) { @@ -13,14 +14,14 @@ module.exports = function({ $bar }) { } async handle() { const result = []; - result.push($bar); + $macros.__MutArray_push(false, result, $bar); if (true) { const bar = "world"; - result.push(bar); + $macros.__MutArray_push(false, result, bar); } const foo = "bang"; - result.push(foo); - return [...(result)]; + $macros.__MutArray_push(false, result, foo); + return $macros.__MutArray_copy(false, result, ); } } return $Closure1; @@ -32,6 +33,7 @@ module.exports = function({ $bar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $fn }) { class $Closure2 { constructor({ }) { @@ -42,9 +44,9 @@ module.exports = function({ $fn }) { async handle() { const result = (await $fn()); $helpers.assert($helpers.eq(result.length, 3), "result.length == 3"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(result, 0), "hola!"), "result.at(0) == \"hola!\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(result, 1), "world"), "result.at(1) == \"world\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(result, 2), "bang"), "result.at(2) == \"bang\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, result, 0), "hola!"), "result.at(0) == \"hola!\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, result, 1), "world"), "result.at(1) == \"world\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, result, 2), "bang"), "result.at(2) == \"bang\""); } } return $Closure2; @@ -74,6 +76,7 @@ module.exports = function({ $fn }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md index b238b029d2c..26a3c73f38b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyEnum }) { class ResourceBackend { async onStop() { @@ -69,6 +70,7 @@ module.exports = function({ $MyEnum }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md index 87c6fd80fb3..30d62838179 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class B extends $A { constructor({ }) { @@ -33,6 +35,7 @@ module.exports = function({ $A }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md index 663a4d0b451..0b9bde65303 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -61,6 +62,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md index adfa04c1368..d0829104308 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md index f1656418946..682a2d40b4d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -34,6 +35,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -69,6 +71,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md index f675086fb84..582e9cdb71c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Animal { constructor({ }) { @@ -18,6 +19,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Animal }) { class Cat extends $Animal { constructor({ }) { @@ -33,6 +35,7 @@ module.exports = function({ $Animal }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Animal }) { class Dog extends $Animal { constructor({ }) { @@ -66,6 +69,7 @@ module.exports = function({ $Animal }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -166,45 +170,45 @@ class $Root extends $stdlib.std.Resource { } } const sArray = ["one", "two"]; - const mutArray = [...(sArray)]; - mutArray.push("three"); - const immutArray = [...(mutArray)]; - const s = ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(sArray, 1); + const mutArray = $macros.__Array_copyMut(false, sArray, ); + $macros.__MutArray_push(false, mutArray, "three"); + const immutArray = $macros.__MutArray_copy(false, mutArray, ); + const s = $macros.__Array_at(false, sArray, 1); $helpers.assert($helpers.eq(s, "two"), "s == \"two\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(sArray, 1), "two"), "sArray.at(1) == \"two\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, sArray, 1), "two"), "sArray.at(1) == \"two\""); $helpers.assert($helpers.eq(sArray.length, 2), "sArray.length == 2"); $helpers.assert($helpers.eq(immutArray.length, 3), "immutArray.length == 3"); const sArray2 = ["if", "you", "build", "it"]; const sArray3 = ["he", "will", "come", "for", "you"]; const mergedArray = (sArray2.concat(sArray3)); $helpers.assert($helpers.eq(mergedArray.length, 9), "mergedArray.length == 9"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(mergedArray, 5), "will"), "mergedArray.at(5) == \"will\""); - $helpers.assert(mergedArray.includes("build"), "mergedArray.contains(\"build\")"); - $helpers.assert((!mergedArray.includes("bring")), "!mergedArray.contains(\"bring\")"); - $helpers.assert($helpers.eq(mergedArray.indexOf("you"), 1), "mergedArray.indexOf(\"you\") == 1"); + $helpers.assert($helpers.eq($macros.__Array_at(false, mergedArray, 5), "will"), "mergedArray.at(5) == \"will\""); + $helpers.assert($macros.__Array_contains(false, mergedArray, "build"), "mergedArray.contains(\"build\")"); + $helpers.assert((!$macros.__Array_contains(false, mergedArray, "bring")), "!mergedArray.contains(\"bring\")"); + $helpers.assert($helpers.eq($macros.__Array_indexOf(false, mergedArray, "you"), 1), "mergedArray.indexOf(\"you\") == 1"); $helpers.assert($helpers.eq((mergedArray.join(" ")), "if you build it he will come for you"), "mergedArray.join(\" \") == \"if you build it he will come for you\""); $helpers.assert($helpers.eq((mergedArray.join()), "if,you,build,it,he,will,come,for,you"), "mergedArray.join() == \"if,you,build,it,he,will,come,for,you\""); - $helpers.assert($helpers.eq(mergedArray.lastIndexOf("you"), 8), "mergedArray.lastIndexOf(\"you\") == 8"); + $helpers.assert($helpers.eq($macros.__Array_lastIndexOf(false, mergedArray, "you"), 8), "mergedArray.lastIndexOf(\"you\") == 8"); const mutArray2 = ["how", "does", "that", "look"]; const mergedMutArray = (mutArray.concat(mutArray2)); $helpers.assert($helpers.eq(mergedMutArray.length, 7), "mergedMutArray.length == 7"); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(mergedMutArray, 5), "that"), "mergedMutArray.at(5) == \"that\""); + $helpers.assert($helpers.eq($macros.__MutArray_at(false, mergedMutArray, 5), "that"), "mergedMutArray.at(5) == \"that\""); const sSet = new Set(["one", "two"]); - const mutSet = new Set(sSet); + const mutSet = $macros.__Set_copyMut(false, sSet, ); (mutSet.add("three")); - const immutSet = new Set(mutSet); + const immutSet = $macros.__MutSet_copy(false, mutSet, ); $helpers.assert((sSet.has("one")), "sSet.has(\"one\")"); $helpers.assert($helpers.eq(sSet.size, 2), "sSet.size == 2"); $helpers.assert($helpers.eq(immutSet.size, 3), "immutSet.size == 3"); const sMap = ({["one"]: 1, ["two"]: 2}); const nestedMap = ({["a"]: ({["b"]: ({"c": "hello"})})}); - const mutMap = {...(sMap)}; - ((obj, args) => { obj[args[0]] = args[1]; })(mutMap, ["five", 5]); - const immutMap = ({...(mutMap)}); - $helpers.assert($helpers.eq(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(sMap, "one"), 1), "sMap.get(\"one\") == 1"); - $helpers.assert($helpers.eq(Object.keys(sMap).length, 2), "sMap.size() == 2"); - $helpers.assert($helpers.eq(Object.keys(immutMap).length, 3), "immutMap.size() == 3"); - $helpers.assert($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(((obj, key) => { if (!(key in obj)) throw new Error(`Map does not contain key: "${key}"`); return obj[key]; })(nestedMap, "a"), "b"), "c"), "hello"), "nestedMap.get(\"a\").get(\"b\").get(\"c\") == \"hello\""); + const mutMap = $macros.__Map_copyMut(false, sMap, ); + $macros.__MutMap_set(false, mutMap, "five", 5); + const immutMap = $macros.__MutMap_copy(false, mutMap, ); + $helpers.assert($helpers.eq($macros.__Map_get(false, sMap, "one"), 1), "sMap.get(\"one\") == 1"); + $helpers.assert($helpers.eq($macros.__Map_size(false, sMap, ), 2), "sMap.size() == 2"); + $helpers.assert($helpers.eq($macros.__Map_size(false, immutMap, ), 3), "immutMap.size() == 3"); + $helpers.assert($helpers.eq($macros.__Json_get(false, $macros.__Map_get(false, $macros.__Map_get(false, nestedMap, "a"), "b"), "c"), "hello"), "nestedMap.get(\"a\").get(\"b\").get(\"c\") == \"hello\""); const heterogeneousArray = [new Cat(this, "C1"), new Dog(this, "D1")]; const heterogeneousDoubleArray = [[new Cat(this, "C2")], [new Cat(this, "C3"), new Dog(this, "D2")], [new Animal(this, "A1")]]; const heterogeneousSet = new Set([new Cat(this, "C4"), new Dog(this, "D3")]); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md index d83bc8b719a..e9abddc6f74 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s1, $s2 }) { class $Closure1 { constructor({ }) { @@ -12,8 +13,8 @@ module.exports = function({ $s1, $s2 }) { return $obj; } async handle() { - console.log(String.raw({ raw: ["index of \"s\" in s1 is ", ""] }, $s1.indexOf("s"))); - console.log(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })((await $s1.split(" ")), 1)); + console.log(String.raw({ raw: ["index of \"s\" in s1 is ", ""] }, $macros.__String_indexOf(false, $s1, "s"))); + console.log($macros.__Array_at(false, (await $s1.split(" ")), 1)); console.log((await $s1.concat($s2))); } } @@ -44,6 +45,7 @@ module.exports = function({ $s1, $s2 }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -98,19 +100,19 @@ class $Root extends $stdlib.std.Resource { const s1 = "some string"; const s2 = "s are immutable"; $helpers.assert($helpers.eq(s1.length, 11), "s1.length == 11"); - $helpers.assert($helpers.eq(((args) => { if (7 >= s1.length || 7 + s1.length < 0) {throw new Error("index out of bounds")}; return s1.at(7) })(7), "r"), "s1.at(7) == \"r\""); + $helpers.assert($helpers.eq($macros.__String_at(false, s1, 7), "r"), "s1.at(7) == \"r\""); $helpers.assert($helpers.eq((s1.concat(s2)), "some strings are immutable"), "s1.concat(s2) == \"some strings are immutable\""); - $helpers.assert(s1.includes("some"), "s1.contains(\"some\")"); - $helpers.assert((!"some".includes(s1)), "!\"some\".contains(s1)"); - $helpers.assert(s1.endsWith("string"), "s1.endsWith(\"string\")"); - $helpers.assert($helpers.eq(s1.indexOf("s"), 0), "s1.indexOf(\"s\") == 0"); - $helpers.assert($helpers.eq("Some String".toLocaleLowerCase(), "some string"), "\"Some String\".lowercase() == \"some string\""); - $helpers.assert($helpers.eq(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })((s1.split(" ")), 0), "some"), "s1.split(\" \").at(0) == \"some\""); - $helpers.assert(s1.startsWith("some"), "s1.startsWith(\"some\")"); + $helpers.assert($macros.__String_contains(false, s1, "some"), "s1.contains(\"some\")"); + $helpers.assert((!$macros.__String_contains(false, "some", s1)), "!\"some\".contains(s1)"); + $helpers.assert($macros.__String_endsWith(false, s1, "string"), "s1.endsWith(\"string\")"); + $helpers.assert($helpers.eq($macros.__String_indexOf(false, s1, "s"), 0), "s1.indexOf(\"s\") == 0"); + $helpers.assert($helpers.eq($macros.__String_lowercase(false, "Some String", ), "some string"), "\"Some String\".lowercase() == \"some string\""); + $helpers.assert($helpers.eq($macros.__Array_at(false, (s1.split(" ")), 0), "some"), "s1.split(\" \").at(0) == \"some\""); + $helpers.assert($macros.__String_startsWith(false, s1, "some"), "s1.startsWith(\"some\")"); $helpers.assert($helpers.eq((s1.substring(5)), "string"), "s1.substring(5) == \"string\""); $helpers.assert($helpers.eq((s1.substring(5, 7)), "st"), "s1.substring(5, 7) == \"st\""); $helpers.assert($helpers.eq((" some string ".trim()), "some string"), "\" some string \".trim() == \"some string\""); - $helpers.assert($helpers.eq("Some String".toLocaleUpperCase(), "SOME STRING"), "\"Some String\".uppercase() == \"SOME STRING\""); + $helpers.assert($helpers.eq($macros.__String_uppercase(false, "Some String", ), "SOME STRING"), "\"Some String\".uppercase() == \"SOME STRING\""); $helpers.assert($helpers.eq(("hello" + " world"), "hello world"), "\"hello\" + \" world\" == \"hello world\""); $helpers.assert($helpers.eq(String.raw({ raw: ["hello ", "\n world"] }, "funky"), "hello funky\n world"), "\n\"hello {\"funky\"}\n world\" == \"hello funky\\n world\""); let initial = "hey, "; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md index a0b311a969d..08cf92bc6a2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_1_b }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $__parent_this_1_b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Store { constructor({ $this_b }) { @@ -42,6 +44,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Util { constructor({ }) { @@ -56,6 +59,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -178,6 +182,7 @@ module.exports = { $preflightTypesMap, Util, Store, Color }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md index b6934a3ae67..532d73b8bc8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md index 47d88e1d1d5..03c974213fc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $cloud_BucketProps, $j }) { class $Closure1 { constructor({ }) { @@ -12,7 +13,7 @@ module.exports = function({ $cloud_BucketProps, $j }) { return $obj; } async handle() { - const x = $cloud_BucketProps._fromJson($j); + const x = $macros.__Struct_fromJson(false, $cloud_BucketProps, $j); $helpers.assert($helpers.eq(x.public, false), "x.public == false"); } } @@ -25,6 +26,7 @@ module.exports = function({ $cloud_BucketProps, $j }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Student }) { class $Closure2 { constructor({ }) { @@ -34,7 +36,7 @@ module.exports = function({ $Student }) { } async handle() { const jStudent3 = ({"firstName": "struct", "lastName": "greatest", "enrolled": true, "schoolId": "s3-inflight", "dob": ({"month": 4, "day": 1, "year": 1999}), "coursesTaken": [({"grade": "B", "dateTaken": ({"month": 5, "day": 10, "year": 2021}), "course": ({"name": "COMP 101", "credits": 2})}), ({"grade": "A", "dateTaken": ({"month": 5, "day": 10, "year": 2021}), "course": ({"name": "COMP 121", "credits": 4})})]}); - const studentInflight1 = $Student._fromJson(jStudent3); + const studentInflight1 = $macros.__Struct_fromJson(false, $Student, jStudent3); $helpers.assert($helpers.eq(studentInflight1.firstName, "struct"), "studentInflight1.firstName == \"struct\""); $helpers.assert($helpers.eq(studentInflight1.lastName, "greatest"), "studentInflight1.lastName == \"greatest\""); $helpers.assert(studentInflight1.enrolled, "studentInflight1.enrolled"); @@ -46,8 +48,8 @@ module.exports = function({ $Student }) { const $if_let_value = studentInflight1.coursesTaken; if ($if_let_value != undefined) { const coursesTaken = $if_let_value; - const course1 = ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(coursesTaken, 0); - const course2 = ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(coursesTaken, 1); + const course1 = $macros.__Array_at(false, coursesTaken, 0); + const course2 = $macros.__Array_at(false, coursesTaken, 1); $helpers.assert($helpers.eq(course1.grade, "B"), "course1.grade == \"B\""); $helpers.assert($helpers.eq(course2.grade, "A"), "course2.grade == \"A\""); } @@ -66,6 +68,7 @@ module.exports = function({ $Student }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Student, $jStudent1 }) { class $Closure3 { constructor({ }) { @@ -74,7 +77,7 @@ module.exports = function({ $Student, $jStudent1 }) { return $obj; } async handle() { - const studentInflight1 = $Student._fromJson($jStudent1); + const studentInflight1 = $macros.__Struct_fromJson(false, $Student, $jStudent1); $helpers.assert($helpers.eq(studentInflight1.firstName, "John"), "studentInflight1.firstName == \"John\""); $helpers.assert($helpers.eq(studentInflight1.lastName, "Smith"), "studentInflight1.lastName == \"Smith\""); $helpers.assert(studentInflight1.enrolled, "studentInflight1.enrolled"); @@ -93,6 +96,7 @@ module.exports = function({ $Student, $jStudent1 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $MyStruct, $expectedSchema, $jMyStruct, $schema, $std_Json }) { class $Closure4 { constructor({ }) { @@ -101,9 +105,9 @@ module.exports = function({ $MyStruct, $expectedSchema, $jMyStruct, $schema, $st return $obj; } async handle() { - const s = $MyStruct; + const s = $macros.__Struct_schema(false, $MyStruct, ); (await s.validate($jMyStruct)); - $helpers.assert($helpers.eq((await $schema.asStr()), ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })($expectedSchema)), "schema.asStr() == Json.stringify(expectedSchema)"); + $helpers.assert($helpers.eq((await $schema.asStr()), $macros.__Json_stringify(false, $std_Json, $expectedSchema)), "schema.asStr() == Json.stringify(expectedSchema)"); } } return $Closure4; @@ -115,6 +119,7 @@ module.exports = function({ $MyStruct, $expectedSchema, $jMyStruct, $schema, $st ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $Student, $std_Boolean, $std_Number, $std_String }) { class $Closure5 { constructor({ }) { @@ -126,7 +131,7 @@ module.exports = function({ $Student, $std_Boolean, $std_Number, $std_String }) (await $std_String.fromJson(10, { unsafe: true })); (await $std_Boolean.fromJson(10, { unsafe: true })); (await $std_Number.fromJson("cool", { unsafe: true })); - $Student._fromJson(({"obviously": "not a student"}), { unsafe: true }); + $macros.__Struct_fromJson(false, $Student, ({"obviously": "not a student"}), { unsafe: true }); } } return $Closure5; @@ -138,6 +143,7 @@ module.exports = function({ $Student, $std_Boolean, $std_Number, $std_String }) ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class UsesStructInImportedFile { constructor({ }) { @@ -170,6 +176,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -396,22 +403,22 @@ class $Root extends $stdlib.std.Resource { } } const j = ({"public": false}); - const x = cloud_BucketProps._fromJson(j); + const x = $macros.__Struct_fromJson(false, cloud_BucketProps, j); $helpers.assert($helpers.eq(x.public, false), "x.public == false"); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight jsii struct conversion", new $Closure1(this, "$Closure1")); const jFoo = ({"f": "bar"}); - $helpers.assert($helpers.eq(Foo._fromJson(jFoo).f, "bar"), "Foo.fromJson(jFoo).f == \"bar\""); + $helpers.assert($helpers.eq($macros.__Struct_fromJson(false, Foo, jFoo).f, "bar"), "Foo.fromJson(jFoo).f == \"bar\""); const jFoosible = ({}); const jFoosible2 = ({"f": "bar"}); { - const $if_let_value = Foosible._fromJson(jFoosible).f; + const $if_let_value = $macros.__Struct_fromJson(false, Foosible, jFoosible).f; if ($if_let_value != undefined) { const f = $if_let_value; $helpers.assert(false, "false"); } } { - const $if_let_value = Foosible._fromJson(jFoosible2).f; + const $if_let_value = $macros.__Struct_fromJson(false, Foosible, jFoosible2).f; if ($if_let_value != undefined) { const f = $if_let_value; $helpers.assert($helpers.eq(f, "bar"), "f == \"bar\""); @@ -421,11 +428,11 @@ class $Root extends $stdlib.std.Resource { } } const jBar = ({"f": "bar", "b": 10}); - const b = Bar._fromJson(jBar); + const b = $macros.__Struct_fromJson(false, Bar, jBar); $helpers.assert($helpers.eq(b.f, "bar"), "b.f == \"bar\""); $helpers.assert($helpers.eq(b.b, 10), "b.b == 10"); const jStudent1 = ({"firstName": "John", "lastName": "Smith", "enrolled": true, "schoolId": "s1-xyz", "dob": ({"month": 10, "day": 10, "year": 2005}), "enrolledCourses": []}); - const student1 = Student._fromJson(jStudent1); + const student1 = $macros.__Struct_fromJson(false, Student, jStudent1); $helpers.assert($helpers.eq(student1.firstName, "John"), "student1.firstName == \"John\""); $helpers.assert($helpers.eq(student1.lastName, "Smith"), "student1.lastName == \"Smith\""); $helpers.assert(student1.enrolled, "student1.enrolled"); @@ -434,7 +441,7 @@ class $Root extends $stdlib.std.Resource { $helpers.assert($helpers.eq(student1.dob.day, 10), "student1.dob.day == 10"); $helpers.assert($helpers.eq(student1.dob.year, 2005), "student1.dob.year == 2005"); const jStudent2 = ({"advisor": ({"firstName": "Tom", "lastName": "Baker", "dob": ({"month": 1, "day": 1, "year": 1983}), "employeeID": "emp123"}), "firstName": "Sally", "lastName": "Reynolds", "enrolled": false, "schoolId": "s2-xyz", "dob": ({"month": 5, "day": 31, "year": 1987}), "enrolledCourses": [({"name": "COMP 101", "credits": 2}), ({"name": "COMP 121", "credits": 4})], "coursesTaken": [({"grade": "F", "dateTaken": ({"month": 5, "day": 10, "year": 2021}), "course": ({"name": "COMP 101", "credits": 2})}), ({"grade": "D", "dateTaken": ({"month": 5, "day": 10, "year": 2021}), "course": ({"name": "COMP 121", "credits": 4})})]}); - const student2 = Student._fromJson(jStudent2); + const student2 = $macros.__Struct_fromJson(false, Student, jStudent2); $helpers.assert($helpers.eq(student2.firstName, "Sally"), "student2.firstName == \"Sally\""); $helpers.assert($helpers.eq(student2.lastName, "Reynolds"), "student2.lastName == \"Reynolds\""); $helpers.assert((!student2.enrolled), "!student2.enrolled"); @@ -446,9 +453,9 @@ class $Root extends $stdlib.std.Resource { const $if_let_value = student2.enrolledCourses; if ($if_let_value != undefined) { const enrolledCourses = $if_let_value; - const courses = [...(enrolledCourses)]; - const s2Course1 = ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(courses, 0); - const s2Course2 = ((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(courses, 1); + const courses = $macros.__Set_toArray(false, enrolledCourses, ); + const s2Course1 = $macros.__Array_at(false, courses, 0); + const s2Course2 = $macros.__Array_at(false, courses, 1); $helpers.assert($helpers.eq(s2Course1.name, "COMP 101"), "s2Course1.name == \"COMP 101\""); $helpers.assert($helpers.eq(s2Course1.credits, 2), "s2Course1.credits == 2"); $helpers.assert($helpers.eq(s2Course2.name, "COMP 121"), "s2Course2.name == \"COMP 121\""); @@ -459,12 +466,12 @@ class $Root extends $stdlib.std.Resource { } } const jStudent3 = ({"enrolled": false, "schoolId": "w/e", "firstName": student2.firstName, "lastName": student2.lastName, "dob": ({"month": 1, "day": 1, "year": 1959}), "additionalData": ({"notes": "wow such notes", "legacy": false, "emergencyContactsNumbers": ["123-345-9928"]})}); - const student3 = Student._fromJson(jStudent3); + const student3 = $macros.__Struct_fromJson(false, Student, jStudent3); { const $if_let_value = student3.additionalData; if ($if_let_value != undefined) { const additionalData = $if_let_value; - const notes = ((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(additionalData, "notes"); + const notes = $macros.__Json_get(false, additionalData, "notes"); $helpers.assert($helpers.eq(notes, "wow such notes"), "notes == \"wow such notes\""); } else { @@ -473,7 +480,7 @@ class $Root extends $stdlib.std.Resource { } const invalidStudent = ({"firstName": "I dont have", "lastName": "Any other info"}); { - const $if_let_value = Student._tryFromJson(invalidStudent); + const $if_let_value = $macros.__Struct_tryFromJson(false, Student, invalidStudent); if ($if_let_value != undefined) { const student = $if_let_value; $helpers.assert(false, "false"); @@ -483,7 +490,7 @@ class $Root extends $stdlib.std.Resource { } } { - const $if_let_value = Student._tryFromJson(jStudent2); + const $if_let_value = $macros.__Struct_tryFromJson(false, Student, jStudent2); if ($if_let_value != undefined) { const student = $if_let_value; $helpers.assert($helpers.eq(student.firstName, "Sally"), "student.firstName == \"Sally\""); @@ -501,21 +508,21 @@ class $Root extends $stdlib.std.Resource { globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:flight school student :)", new $Closure2(this, "$Closure2")); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:lifting a student", new $Closure3(this, "$Closure3")); const jj1 = ({"data": ({"val": 10})}); - const externalBar = externalStructs_MyOtherStruct._fromJson(jj1); + const externalBar = $macros.__Struct_fromJson(false, externalStructs_MyOtherStruct, jj1); $helpers.assert($helpers.eq(externalBar.data.val, 10), "externalBar.data.val == 10"); const jMyStruct = ({"m1": ({"val": 10}), "m2": ({"val": "10"})}); - const myStruct = MyStruct._fromJson(jMyStruct); + const myStruct = $macros.__Struct_fromJson(false, MyStruct, jMyStruct); $helpers.assert($helpers.eq(myStruct.m1.val, 10), "myStruct.m1.val == 10"); $helpers.assert($helpers.eq(myStruct.m2.val, "10"), "myStruct.m2.val == \"10\""); - const schema = MyStruct; + const schema = $macros.__Struct_schema(false, MyStruct, ); (schema.validate(jMyStruct)); const expectedSchema = ({"$id": "/MyStruct", "type": "object", "properties": ({"m1": ({"type": "object", "properties": ({"val": ({"type": "number"})}), "required": ["val"]}), "m2": ({"type": "object", "properties": ({"val": ({"type": "string"})}), "required": ["val"]})}), "required": ["m1", "m2"]}); - $helpers.assert($helpers.eq((schema.asStr()), ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(expectedSchema)), "schema.asStr() == Json.stringify(expectedSchema)"); + $helpers.assert($helpers.eq((schema.asStr()), $macros.__Json_stringify(false, std.Json, expectedSchema)), "schema.asStr() == Json.stringify(expectedSchema)"); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight schema usage", new $Closure4(this, "$Closure4")); (std.String.fromJson(10, { unsafe: true })); (std.Boolean.fromJson(10, { unsafe: true })); (std.Number.fromJson("cool", { unsafe: true })); - Student._fromJson(({"obviously": "not a student"}), { unsafe: true }); + $macros.__Struct_fromJson(false, Student, ({"obviously": "not a student"}), { unsafe: true }); globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:unsafe flight", new $Closure5(this, "$Closure5")); new otherExternalStructs.UsesStructInImportedFile(this, "UsesStructInImportedFile"); } @@ -529,6 +536,7 @@ $APP.synth(); ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -541,6 +549,7 @@ module.exports = { $preflightTypesMap, }; ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); @@ -549,7 +558,7 @@ const SomeStruct = $stdlib.std.Struct._createJsonSchema({$id:"/SomeStruct",type: class UsesStructInImportedFile extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); - this.someStruct = SomeStruct._fromJson(({"foo": "123"})); + this.someStruct = $macros.__Struct_fromJson(false, SomeStruct, ({"foo": "123"})); } static _toInflightType() { return ` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md index 71d4be4085d..345c6d4c9e0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ $this_data_field0 }) { @@ -61,6 +63,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -151,7 +154,7 @@ class $Root extends $stdlib.std.Resource { globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:struct definitions are phase independant", new $Closure1(this, "$Closure1")); const aNode = ({"val": "someval"}); const bNode = ({"val": "otherval", "next": aNode}); - (expect.Util.equal(((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(bNode), "{\"val\":\"otherval\",\"next\":{\"val\":\"someval\"\}\}")); + (expect.Util.equal($macros.__Json_stringify(false, std.Json, bNode), "{\"val\":\"otherval\",\"next\":{\"val\":\"someval\"\}\}")); const numField = 1337; const strField = "leet"; const boolField = true; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md index b8223a7cc9b..718e5542af7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $InflightB, $expect_Util }) { class $Closure1 { constructor({ }) { @@ -25,6 +26,7 @@ module.exports = function({ $InflightB, $expect_Util }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $expect_Util, $extended }) { class $Closure2 { constructor({ }) { @@ -45,6 +47,7 @@ module.exports = function({ $expect_Util, $extended }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -59,6 +62,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $A }) { class B extends $A { constructor({ }) { @@ -74,6 +78,7 @@ module.exports = function({ $A }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class BaseClass { constructor({ }) { @@ -91,6 +96,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $B }) { class C extends $B { constructor({ }) { @@ -106,6 +112,7 @@ module.exports = function({ $B }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $C }) { class D extends $C { constructor({ }) { @@ -121,6 +128,7 @@ module.exports = function({ $C }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $D }) { class E extends $D { constructor({ }) { @@ -136,6 +144,7 @@ module.exports = function({ $D }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $BaseClass, $b }) { class ExtendedClass extends $BaseClass { constructor({ }) { @@ -155,6 +164,7 @@ module.exports = function({ $BaseClass, $b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class InflightA { async description() { @@ -170,6 +180,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $InflightA }) { class InflightB extends $InflightA { async description() { @@ -217,6 +228,7 @@ module.exports = function({ $InflightA }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md index b905f077f0b..9b7387b3ffc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $s }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $s }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $s }) { class $Closure3 { constructor({ }) { @@ -64,6 +67,7 @@ module.exports = function({ $s }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure4 { constructor({ }) { @@ -85,6 +89,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class A { constructor({ }) { @@ -117,6 +122,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md index 7b8daea5bba..266442f2838 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -26,6 +27,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure2 { constructor({ }) { @@ -79,6 +81,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md index 75fd00ce354..5f7f96bd1a8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -42,6 +43,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md index 4f032bfe81f..039922f4beb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -41,7 +42,7 @@ class $Root extends $stdlib.std.Resource { console.log($helpers.nodeof(c).path); } (expect.Util.notNil($helpers.nodeof(this))); - (expect.Util.equal(((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(($helpers.nodeof(this).path.split("/")), 0), "root")); + (expect.Util.equal($macros.__Array_at(false, ($helpers.nodeof(this).path.split("/")), 0), "root")); } } const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "this.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md index 2c2dc0c0c09..217b21aedca 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class $Closure1 { constructor({ }) { @@ -56,6 +57,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; @@ -108,7 +110,7 @@ class $Root extends $stdlib.std.Resource { const b = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket"); const x = new $Closure1(this, "$Closure1"); const js = (std.Resource.toInflight(x)); - $helpers.assert(js.includes("client"), "js.contains(\"client\")"); + $helpers.assert($macros.__String_contains(false, js, "client"), "js.contains(\"client\")"); } } const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "to_inflight.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md index 3a83437a1b6..66ab02c989d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md index b44d7368fa1..41040098a53 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $f }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $f }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $bar }) { class $Closure2 { constructor({ }) { @@ -44,6 +46,7 @@ module.exports = function({ $bar }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class Bar { constructor({ }) { @@ -63,6 +66,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $b }) { class Foo { constructor({ }) { @@ -114,6 +118,7 @@ module.exports = function({ $b }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md index ac5618c430b..febfa921a64 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $__parent_this_1 }) { class $Closure1 { constructor({ }) { @@ -24,6 +25,7 @@ module.exports = function({ $__parent_this_1 }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class Foo { constructor({ }) { @@ -167,6 +169,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md index 03b5d43ffb5..d0067a1399a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $std_Json, $userData }) { class $Closure1 { constructor({ }) { @@ -12,7 +13,7 @@ module.exports = function({ $std_Json, $userData }) { return $obj; } async handle(req) { - return ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"users": (await $userData.list())})), "status": 200}); + return ({"body": $macros.__Json_stringify(false, $std_Json, ({"users": (await $userData.list())})), "status": 200}); } } return $Closure1; @@ -24,6 +25,7 @@ module.exports = function({ $std_Json, $userData }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $std_Json, $userData }) { class $Closure2 { constructor({ }) { @@ -32,12 +34,12 @@ module.exports = function({ $std_Json, $userData }) { return $obj; } async handle(req) { - const body = JSON.parse((req.body ?? "")); - if ((($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "name"), "") || $helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "age"), "")) || $helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "id"), ""))) { - return ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"error": "incomplete details"})), "status": 400}); + const body = $macros.__Json_parse(false, $std_Json, (req.body ?? "")); + if ((($helpers.eq($macros.__Json_get(false, body, "name"), "") || $helpers.eq($macros.__Json_get(false, body, "age"), "")) || $helpers.eq($macros.__Json_get(false, body, "id"), ""))) { + return ({"body": $macros.__Json_stringify(false, $std_Json, ({"error": "incomplete details"})), "status": 400}); } - (await $userData.putJson(((arg) => { if (typeof arg !== "string") {throw new Error("unable to parse " + typeof arg + " " + arg + " as a string")}; return JSON.parse(JSON.stringify(arg)) })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "id")), body)); - return ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"user": ((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "id")})), "status": 201}); + (await $userData.putJson($macros.__Json_asStr(false, $macros.__Json_get(false, body, "id"), ), body)); + return ({"body": $macros.__Json_stringify(false, $std_Json, ({"user": $macros.__Json_get(false, body, "id")})), "status": 201}); } } return $Closure2; @@ -49,6 +51,7 @@ module.exports = function({ $std_Json, $userData }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util }) { class $Closure3 { constructor({ }) { @@ -60,11 +63,11 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util const response = (await $http_Util.fetch(($api_url + "/users"), ({"method": $http_HttpMethod.GET, "headers": ({"Content-Type": "text/json"})}))); const headers = response.headers; (await $expect_Util.equal(response.status, 200)); - (await $expect_Util.equal((headers)["access-control-allow-origin"], "*")); - (await $expect_Util.equal((headers)["access-control-expose-headers"], "Content-Type")); - (await $expect_Util.equal((headers)["access-control-allow-credentials"], "false")); - (await $expect_Util.nil((headers)["access-control-allow-headers"])); - (await $expect_Util.nil((headers)["access-control-allow-methods"])); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-origin"), "*")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-expose-headers"), "Content-Type")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-credentials"), "false")); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-headers"))); + (await $expect_Util.nil($macros.__Map_tryGet(false, headers, "access-control-allow-methods"))); } } return $Closure3; @@ -76,6 +79,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util }) { class $Closure4 { constructor({ }) { @@ -87,8 +91,8 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util const response = (await $http_Util.fetch(($api_url + "/users"), ({"method": $http_HttpMethod.OPTIONS, "headers": ({"Content-Type": "text/json"})}))); const headers = response.headers; (await $expect_Util.equal(response.status, 204)); - (await $expect_Util.equal((headers)["access-control-allow-methods"], "GET,POST,OPTIONS")); - (await $expect_Util.equal((headers)["access-control-allow-headers"], "Content-Type")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-methods"), "GET,POST,OPTIONS")); + (await $expect_Util.equal($macros.__Map_tryGet(false, headers, "access-control-allow-headers"), "Content-Type")); } } return $Closure4; @@ -612,6 +616,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md index 2e607c3dda4..515dbf9add5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md @@ -22,6 +22,7 @@ ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md index e26ba569d0b..ba40336e16f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md @@ -4,6 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); +const $macros = require("@winglang/sdk/lib/macros"); module.exports = function({ }) { class $Closure1 { constructor({ }) { @@ -186,6 +187,7 @@ module.exports = function({ }) { ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); +const $macros = require("@winglang/sdk/lib/macros"); const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true";