From 1a83d656077ca7497f5d2d740f2ac7acbd0a407a Mon Sep 17 00:00:00 2001 From: Chris Rybicki Date: Mon, 26 Jun 2023 18:10:26 -0400 Subject: [PATCH] fix(compiler): assert doesn't work with string interpolation (#3038) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1833 The high level idea behind this fix is to avoid using backtick-strings in our generated JavaScript. These lead to a lot of issues that can be avoided by using other concatenation strategies that do not introduce grammar complexities. In this case, I decided to use `String.raw()`, but translating interpolated strings into a sequence of `+` operations probably could have worked too. The other major change I did was improving the errors emitted by `assert()` so that it shows the original Wing source code that you asserted, not the emitted JavaScript. For example, now an error looks like: ``` assertion failed: b.list().length == 1 ``` 




instead of:

 ``` assertion failed: '((await b.list()).length === 1)' ``` ## Checklist - [x] Title matches [Winglang's style guide](https://docs.winglang.io/contributors/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Monada Contribution License](https://docs.winglang.io/terms-and-policies/contribution-license.html)*. --- examples/tests/valid/assert.w | 36 +++ .../tests/valid/json_string_interpolation.w | 2 +- libs/wingc/src/ast.rs | 4 +- libs/wingc/src/closure_transform.rs | 1 + libs/wingc/src/{jsify => }/files.rs | 5 + libs/wingc/src/fold.rs | 1 + libs/wingc/src/jsify.rs | 149 ++++++++--- libs/wingc/src/lib.rs | 32 ++- libs/wingc/src/lsp/sync.rs | 23 +- libs/wingc/src/parser.rs | 31 ++- libs/wingc/src/type_check.rs | 1 + tools/hangar/__snapshots__/error.ts.snap | 8 +- .../sdk_tests/api/delete.w_compile_tf-aws.md | 22 +- .../sdk_tests/api/get.w_compile_tf-aws.md | 24 +- .../sdk_tests/api/patch.w_compile_tf-aws.md | 24 +- .../sdk_tests/api/post.w_compile_tf-aws.md | 20 +- .../sdk_tests/api/put.w_compile_tf-aws.md | 28 +- .../bucket/add_object.w_compile_tf-aws.md | 6 +- .../bucket/bucket_list.w_compile_tf-aws.md | 22 +- .../bucket/delete.w_compile_tf-aws.md | 10 +- .../bucket/events.w_compile_tf-aws.md | 26 +- .../bucket/exists.w_compile_tf-aws.md | 8 +- .../bucket/public_url.w_compile_tf-aws.md | 4 +- .../sdk_tests/bucket/put.w_compile_tf-aws.md | 10 +- .../bucket/put_json.w_compile_tf-aws.md | 10 +- .../bucket/try_delete.w_compile_tf-aws.md | 14 +- .../bucket/try_get.w_compile_tf-aws.md | 8 +- .../bucket/try_get_json.w_compile_tf-aws.md | 10 +- .../sdk_tests/counter/dec.w_compile_tf-aws.md | 20 +- .../sdk_tests/counter/inc.w_compile_tf-aws.md | 32 +-- .../counter/initial.w_compile_tf-aws.md | 6 +- .../counter/peek.w_compile_tf-aws.md | 12 +- .../sdk_tests/counter/set.w_compile_tf-aws.md | 20 +- .../function/invoke.w_compile_tf-aws.md | 6 +- .../memory_and_env.w_compile_tf-aws.md | 10 +- .../sdk_tests/queue/pop.w_compile_tf-aws.md | 6 +- .../sdk_tests/queue/purge.w_compile_tf-aws.md | 10 +- .../queue/set_consumer.w_compile_tf-aws.md | 4 +- .../schedule/on_tick.w_compile_tf-aws.md | 8 +- .../sdk_tests/std/array.w_compile_tf-aws.md | 168 ++++++------ .../sdk_tests/std/bool.w_compile_tf-aws.md | 2 +- .../std/duration.w_compile_tf-aws.md | 80 +++--- .../sdk_tests/std/json.w_compile_tf-aws.md | 8 +- .../sdk_tests/std/map.w_compile_tf-aws.md | 12 +- .../sdk_tests/std/number.w_compile_tf-aws.md | 8 +- .../sdk_tests/std/string.w_compile_tf-aws.md | 22 +- .../table/add_row.w_compile_tf-aws.md | 4 +- .../sdk_tests/table/list.w_compile_tf-aws.md | 8 +- .../topic/on_message.w_compile_tf-aws.md | 4 +- .../sdk_tests/util/env.w_compile_tf-aws.md | 12 +- .../sdk_tests/util/sleep.w_compile_tf-aws.md | 2 +- .../util/wait-until.w_compile_tf-aws.md | 20 +- .../website/website.w_compile_tf-aws.md | 8 +- .../valid/anon_function.w_compile_tf-aws.md | 4 +- .../test_corpus/valid/api.w_compile_tf-aws.md | 4 +- .../valid/api_path_vars.w_compile_tf-aws.md | 6 +- .../valid/api_valid_path.w_compile_tf-aws.md | 6 +- .../valid/assert.w_compile_tf-aws.md | 246 ++++++++++++++++++ .../test_corpus/valid/assert.w_test_sim.md | 15 ++ .../valid/bring_jsii.w_compile_tf-aws.md | 2 +- .../valid/bring_jsii_path.w_compile_tf-aws.md | 2 +- .../valid/bring_projen.w_compile_tf-aws.md | 2 +- .../valid/bucket_events.w_compile_tf-aws.md | 8 +- .../valid/bucket_keys.w_compile_tf-aws.md | 10 +- ...ling_inflight_variants.w_compile_tf-aws.md | 10 +- .../capture_containers.w_compile_tf-aws.md | 18 +- .../capture_in_binary.w_compile_tf-aws.md | 4 +- .../capture_mutables.w_compile_tf-aws.md | 8 +- .../capture_primitives.w_compile_tf-aws.md | 8 +- ...eassigable_class_field.w_compile_tf-aws.md | 10 +- .../capture_reassignable.w_compile_tf-aws.md | 2 +- ...ture_resource_and_data.w_compile_tf-aws.md | 4 +- ...ource_with_no_inflight.w_compile_tf-aws.md | 2 +- .../valid/capture_tokens.w_compile_tf-aws.md | 8 +- .../valid/class.w_compile_tf-aws.md | 24 +- .../valid/construct-base.w_compile_tf-aws.md | 8 +- .../valid/container_types.w_compile_tf-aws.md | 124 ++++----- .../valid/doubler.w_compile_tf-aws.md | 4 +- ...sions_binary_operators.w_compile_tf-aws.md | 10 +- ...s_string_interpolation.w_compile_tf-aws.md | 8 +- .../extern_implementation.w_compile_tf-aws.md | 10 +- .../valid/file_counter.w_compile_tf-aws.md | 2 +- .../valid/for_loop.w_compile_tf-aws.md | 120 ++++----- .../valid/forward_decl.w_compile_tf-aws.md | 4 +- ...ction_returns_function.w_compile_tf-aws.md | 8 +- .../valid/hello.w_compile_tf-aws.md | 2 +- .../valid/implicit_std.w_compile_tf-aws.md | 4 +- ...nflight_capture_static.w_compile_tf-aws.md | 12 +- ...lass_as_struct_members.w_compile_tf-aws.md | 2 +- ...ht_class_capture_const.w_compile_tf-aws.md | 2 +- ...ight_class_definitions.w_compile_tf-aws.md | 14 +- ..._inner_capture_mutable.w_compile_tf-aws.md | 6 +- ...nside_inflight_closure.w_compile_tf-aws.md | 4 +- ...tside_inflight_closure.w_compile_tf-aws.md | 2 +- ...tural_interace_handler.w_compile_tf-aws.md | 4 +- ...ghts_calling_inflights.w_compile_tf-aws.md | 4 +- .../valid/json.w_compile_tf-aws.md | 24 +- .../valid/json_bucket.w_compile_tf-aws.md | 2 +- .../valid/json_static.w_compile_tf-aws.md | 32 +-- ...n_string_interpolation.w_compile_tf-aws.md | 8 +- .../mut_container_types.w_compile_tf-aws.md | 28 +- .../test_corpus/valid/nil.w_compile_tf-aws.md | 14 +- .../valid/optionals.w_compile_tf-aws.md | 48 ++-- .../primitive_methods.w_compile_tf-aws.md | 6 +- .../valid/reassignment.w_compile_tf-aws.md | 10 +- .../valid/redis.w_compile_tf-aws.md | 4 +- .../valid/resource.w_compile_tf-aws.md | 24 +- ...ce_as_inflight_literal.w_compile_tf-aws.md | 2 +- .../resource_captures.w_compile_tf-aws.md | 50 ++-- ...ource_captures_globals.w_compile_tf-aws.md | 22 +- .../valid/shadowing.w_compile_tf-aws.md | 8 +- .../valid/statements_if.w_compile_tf-aws.md | 22 +- .../valid/static_members.w_compile_tf-aws.md | 8 +- .../valid/std_containers.w_compile_tf-aws.md | 42 +-- .../valid/std_string.w_compile_tf-aws.md | 32 +-- .../valid/structs.w_compile_tf-aws.md | 6 +- .../valid/symbol_shadow.w_compile_tf-aws.md | 14 +- .../valid/test_bucket.w_compile_tf-aws.md | 6 +- .../test_without_bring.w_compile_tf-aws.md | 2 +- .../valid/try_catch.w_compile_tf-aws.md | 42 +-- .../valid/while.w_compile_tf-aws.md | 6 +- .../while_loop_await.w_compile_tf-aws.md | 2 +- 122 files changed, 1325 insertions(+), 927 deletions(-) create mode 100644 examples/tests/valid/assert.w rename libs/wingc/src/{jsify => }/files.rs (96%) create mode 100644 tools/hangar/__snapshots__/test_corpus/valid/assert.w_compile_tf-aws.md create mode 100644 tools/hangar/__snapshots__/test_corpus/valid/assert.w_test_sim.md diff --git a/examples/tests/valid/assert.w b/examples/tests/valid/assert.w new file mode 100644 index 00000000000..3e38d3716bf --- /dev/null +++ b/examples/tests/valid/assert.w @@ -0,0 +1,36 @@ +let s1 = "foo"; +let s2 = "bar"; + +assert("" == ""); +assert("'" == "'"); +assert("\"" == "\""); +assert("`" == "`"); +assert("``" == "``"); +assert("`s1`" == "`s1`"); +assert(s1 == s1); +assert("${s1}" == "${s1}"); +assert("${s1}" != "${s2}"); +assert("a${s1}" == "a${s1}"); +assert("a${s1}" != "b${s1}"); +assert("${s1}a" == "${s1}a"); +assert("${s1}a" != "${s1}b"); +assert("`'${s1}" == "`'${s1}"); +assert("a${s1}b${s2}c" == "a${s1}b${s2}c"); + +test "assert works inflight" { + assert("" == ""); + assert("'" == "'"); + assert("\"" == "\""); + assert("`" == "`"); + assert("``" == "``"); + assert("`s1`" == "`s1`"); + assert(s1 == s1); + assert("${s1}" == "${s1}"); + assert("${s1}" != "${s2}"); + assert("a${s1}" == "a${s1}"); + assert("a${s1}" != "b${s1}"); + assert("${s1}a" == "${s1}a"); + assert("${s1}a" != "${s1}b"); + assert("`'${s1}" == "`'${s1}"); + assert("a${s1}b${s2}c" == "a${s1}b${s2}c"); +} diff --git a/examples/tests/valid/json_string_interpolation.w b/examples/tests/valid/json_string_interpolation.w index 266a271a090..66f4f6abfa4 100644 --- a/examples/tests/valid/json_string_interpolation.w +++ b/examples/tests/valid/json_string_interpolation.w @@ -6,4 +6,4 @@ let obj = Json { let notStringifyStrValue = "string: ${obj.get("strValue")}"; assert(notStringifyStrValue == "string: test"); let stringifyNumValue = "number: ${obj.get("numValue")}"; -assert(stringifyNumValue == "number: 1"); \ No newline at end of file +assert(stringifyNumValue == "number: 1"); diff --git a/libs/wingc/src/ast.rs b/libs/wingc/src/ast.rs index 9f269cdd83a..7e3ffd72208 100644 --- a/libs/wingc/src/ast.rs +++ b/libs/wingc/src/ast.rs @@ -494,13 +494,15 @@ impl Expr { pub struct ArgList { pub pos_args: Vec, pub named_args: IndexMap, + pub span: WingSpan, } impl ArgList { - pub fn new() -> Self { + pub fn new(span: WingSpan) -> Self { ArgList { pos_args: vec![], named_args: IndexMap::new(), + span, } } } diff --git a/libs/wingc/src/closure_transform.rs b/libs/wingc/src/closure_transform.rs index a2fb8e4bed7..e01ff30f388 100644 --- a/libs/wingc/src/closure_transform.rs +++ b/libs/wingc/src/closure_transform.rs @@ -276,6 +276,7 @@ impl Fold for ClosureTransformer { arg_list: ArgList { named_args: IndexMap::new(), pos_args: vec![], + span: WingSpan::default(), }, obj_id: None, obj_scope: None, diff --git a/libs/wingc/src/jsify/files.rs b/libs/wingc/src/files.rs similarity index 96% rename from libs/wingc/src/jsify/files.rs rename to libs/wingc/src/files.rs index 69e27250f53..cd5113a134f 100644 --- a/libs/wingc/src/jsify/files.rs +++ b/libs/wingc/src/files.rs @@ -35,6 +35,7 @@ impl From for Diagnostic { impl Error for FilesError {} +#[derive(Default)] pub struct Files { data: HashMap, } @@ -53,6 +54,10 @@ impl Files { Ok(()) } + pub fn get_file>(&self, path: S) -> Option<&String> { + self.data.get(path.as_ref()) + } + pub fn emit_files(&self, out_dir: &Path) -> Result<(), FilesError> { for (path, content) in &self.data { let full_path = out_dir.join(path); diff --git a/libs/wingc/src/fold.rs b/libs/wingc/src/fold.rs index 71c66a9b368..0311466ae43 100644 --- a/libs/wingc/src/fold.rs +++ b/libs/wingc/src/fold.rs @@ -417,6 +417,7 @@ where .into_iter() .map(|(name, arg)| (f.fold_symbol(name), f.fold_expr(arg))) .collect(), + span: node.span, } } diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index ae2ec8792c4..0bf924f30b8 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1,5 +1,4 @@ pub mod codemaker; -mod files; use aho_corasick::AhoCorasick; use const_format::formatcp; @@ -24,16 +23,18 @@ use crate::{ comp_ctx::{CompilationContext, CompilationPhase}, dbg_panic, debug, diagnostic::{report_diagnostic, Diagnostic, WingSpan}, + files::Files, type_check::{ resolve_user_defined_type, symbol_env::{LookupResult, SymbolEnv, SymbolEnvRef}, ClassLike, SymbolKind, Type, TypeRef, Types, UnsafeRef, VariableInfo, CLASS_INFLIGHT_INIT_NAME, HANDLE_METHOD_NAME, }, visit::{self, Visit}, - MACRO_REPLACE_ARGS, MACRO_REPLACE_SELF, WINGSDK_ASSEMBLY_NAME, WINGSDK_RESOURCE, WINGSDK_STD_MODULE, + MACRO_REPLACE_ARGS, MACRO_REPLACE_ARGS_TEXT, MACRO_REPLACE_SELF, WINGSDK_ASSEMBLY_NAME, WINGSDK_RESOURCE, + WINGSDK_STD_MODULE, }; -use self::{codemaker::CodeMaker, files::Files}; +use self::codemaker::CodeMaker; const PREFLIGHT_FILE_NAME: &str = "preflight.js"; @@ -62,8 +63,8 @@ pub struct JSifyContext { pub struct JSifier<'a> { pub types: &'a Types, - /// Stores all generated JS files in memory. - files: Files, + source_files: &'a Files, + emitted_files: Files, /// Root of the project, used for resolving extern modules absolute_project_root: &'a Path, shim: bool, @@ -79,10 +80,17 @@ enum BindMethod { } impl<'a> JSifier<'a> { - pub fn new(types: &'a Types, app_name: &'a str, absolute_project_root: &'a Path, shim: bool) -> Self { + pub fn new( + types: &'a Types, + source_files: &'a Files, + app_name: &'a str, + absolute_project_root: &'a Path, + shim: bool, + ) -> Self { Self { types, - files: Files::new(), + source_files, + emitted_files: Files::new(), shim, app_name, absolute_project_root, @@ -180,7 +188,7 @@ impl<'a> JSifier<'a> { output.add_code(js); } - match self.files.add_file(PREFLIGHT_FILE_NAME, output.to_string()) { + match self.emitted_files.add_file(PREFLIGHT_FILE_NAME, output.to_string()) { Ok(()) => {} Err(err) => report_diagnostic(err.into()), } @@ -188,7 +196,7 @@ impl<'a> JSifier<'a> { /// Write all files to the output directory pub fn emit_files(&mut self, out_dir: &Path) { - match self.files.emit_files(out_dir) { + match self.emitted_files.emit_files(out_dir) { Ok(()) => {} Err(err) => report_diagnostic(err.into()), } @@ -337,26 +345,34 @@ impl<'a> JSifier<'a> { } } ExprKind::Literal(lit) => match lit { - Literal::Nil => "undefined".to_string(), + Literal::Nil => "undefined".to_string(), Literal::String(s) => s.to_string(), - Literal::InterpolatedString(s) => format!( - "`{}`", - s.parts + Literal::InterpolatedString(s) => { + let comma_separated_statics = s + .parts .iter() - .map(|p| match p { - InterpolatedStringPart::Static(l) => l.to_string(), - InterpolatedStringPart::Expr(e) => { - match *self.get_expr_type(e) { - Type::Json | Type::MutJson => { - format!("${{((e) => typeof e === 'string' ? e : JSON.stringify(e, null, 2))({})}}", self.jsify_expression(e, ctx)) - } - _ => format!("${{{}}}", self.jsify_expression(e, ctx)), + .filter_map(|p| match p { + InterpolatedStringPart::Static(l) => Some(format!("\"{}\"", l.to_string())), + InterpolatedStringPart::Expr(_) => None, + }) + .collect::>() + .join(", "); + let comma_separated_exprs = s + .parts + .iter() + .filter_map(|p| match p { + InterpolatedStringPart::Static(_) => None, + InterpolatedStringPart::Expr(e) => Some(match *self.get_expr_type(e) { + Type::Json | Type::MutJson => { + format!("((e) => typeof e === 'string' ? e : JSON.stringify(e, null, 2))({})", self.jsify_expression(e, ctx)) } - } + _ => self.jsify_expression(e, ctx), + }) }) .collect::>() - .join("") - ), + .join(", "); + format!("String.raw({{ raw: [{}] }}, {})", comma_separated_statics, comma_separated_exprs) + }, Literal::Number(n) => format!("{}", n), Literal::Boolean(b) => (if *b { "true" } else { "false" }).to_string(), }, @@ -386,7 +402,13 @@ impl<'a> JSifier<'a> { ExprKind::Reference(reference) => self.jsify_reference(reference, ctx), _ => format!("({})", self.jsify_expression(callee, ctx)), }; - let arg_string = self.jsify_arg_list(&arg_list, None, None, ctx); + let args_string = self.jsify_arg_list(&arg_list, None, None, ctx); + let mut args_text_string = lookup_span(&arg_list.span, &self.source_files); + if args_text_string.len() > 0 { + // remove the parens + args_text_string = args_text_string[1..args_text_string.len() - 1].to_string(); + } + let args_text_string = escape_javascript_string(&args_text_string); if let Some(function_sig) = function_sig { if let Some(js_override) = &function_sig.js_override { @@ -399,8 +421,8 @@ impl<'a> JSifier<'a> { _ => expr_string, }; - let patterns = &[MACRO_REPLACE_SELF, MACRO_REPLACE_ARGS]; - let replace_with = &[self_string, &arg_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); return ac.replace_all(js_override, replace_with); } @@ -408,7 +430,7 @@ impl<'a> JSifier<'a> { // NOTE: if the expression is a "handle" class, the object itself is callable (see // `jsify_class_inflight` below), so we can just call it as-is. - format!("({auto_await}{expr_string}({arg_string}))") + format!("({auto_await}{expr_string}({args_string}))") } ExprKind::Unary { op, exp } => { let js_exp = self.jsify_expression(exp, ctx); @@ -1312,7 +1334,7 @@ impl<'a> JSifier<'a> { code.line(format!("return {name};")); code.close("}"); - match self.files.add_file(inflight_filename(class), code.to_string()) { + match self.emitted_files.add_file(inflight_filename(class), code.to_string()) { Ok(()) => {} Err(err) => report_diagnostic(err.into()), } @@ -1961,3 +1983,72 @@ fn jsify_type_name(t: &Vec, phase: Phase) -> String { p.join(".") } } + +fn lookup_span(span: &WingSpan, files: &Files) -> String { + let source = files + .get_file(&span.file_id) + .expect(&format!("failed to find source file with id {}", span.file_id)); + let lines = source.lines().collect_vec(); + + let start_line = span.start.line as usize; + let end_line = span.end.line as usize; + + let start_col = span.start.col as usize; + let end_col = span.end.col as usize; + + let mut result = String::new(); + + if start_line == end_line { + result.push_str(&lines[start_line][start_col..end_col]); + } else { + result.push_str(&lines[start_line][start_col..]); + result.push('\n'); + + for line in lines[start_line + 1..end_line].iter() { + result.push_str(line); + result.push('\n'); + } + + result.push_str(&lines[end_line][..end_col]); + } + + result +} + +fn escape_javascript_string(s: &str) -> String { + let mut result = String::new(); + + // escape all escapable characters -- see the section "Escape sequences" in + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#literals + for c in s.chars() { + match c { + '\0' => result.push_str("\\0"), + '\'' => result.push_str("\\'"), + '"' => result.push_str("\\\""), + '\\' => result.push_str("\\\\"), + '\n' => result.push_str("\\n"), + '\r' => result.push_str("\\r"), + '\t' => result.push_str("\\t"), + _ => result.push(c), + } + } + + result +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_escape_javascript_string() { + assert_eq!(escape_javascript_string("hello"), String::from("hello")); + assert_eq!(escape_javascript_string("hello\nworld"), String::from("hello\\nworld")); + assert_eq!(escape_javascript_string("hello\rworld"), String::from("hello\\rworld")); + assert_eq!(escape_javascript_string("hello\tworld"), String::from("hello\\tworld")); + assert_eq!(escape_javascript_string("hello\\world"), String::from("hello\\\\world")); + assert_eq!(escape_javascript_string("hello'world"), String::from("hello\\'world")); + assert_eq!(escape_javascript_string("hello\"world"), String::from("hello\\\"world")); + assert_eq!(escape_javascript_string("hello\0world"), String::from("hello\\0world")); + } +} diff --git a/libs/wingc/src/lib.rs b/libs/wingc/src/lib.rs index d7914c459a5..99941be2f1c 100644 --- a/libs/wingc/src/lib.rs +++ b/libs/wingc/src/lib.rs @@ -11,6 +11,7 @@ use ast::{Scope, Stmt, Symbol, UtilityFunctions}; use closure_transform::ClosureTransformer; use comp_ctx::set_custom_panic_hook; use diagnostic::{found_errors, report_diagnostic, Diagnostic}; +use files::Files; use fold::Fold; use jsify::JSifier; use type_check::jsii_importer::JsiiImportSpec; @@ -39,6 +40,7 @@ mod comp_ctx; pub mod debug; pub mod diagnostic; mod docs; +mod files; pub mod fold; pub mod jsify; pub mod lsp; @@ -73,6 +75,7 @@ const CONSTRUCT_BASE_CLASS: &'static str = "constructs.Construct"; const MACRO_REPLACE_SELF: &'static str = "$self$"; const MACRO_REPLACE_ARGS: &'static str = "$args$"; +const MACRO_REPLACE_ARGS_TEXT: &'static str = "$args_text$"; pub struct CompilerOutput {} @@ -135,7 +138,7 @@ pub unsafe extern "C" fn wingc_compile(ptr: u32, len: u32) -> u64 { } } -pub fn parse(source_path: &Path) -> Scope { +pub fn parse(source_path: &Path) -> (Files, Scope) { let language = tree_sitter_wing::language(); let mut parser = tree_sitter::Parser::new(); parser.set_language(language).unwrap(); @@ -154,20 +157,31 @@ pub fn parse(source_path: &Path) -> Scope { env: RefCell::new(None), span: Default::default(), }; - return empty_scope; + return (Files::default(), empty_scope); } }; - let tree = match parser.parse(&source[..], None) { + let mut files = Files::new(); + match files.add_file( + source_path.to_path_buf(), + String::from_utf8(source.clone()).expect("Invalid UTF-8 sequence"), + ) { + Ok(_) => {} + Err(err) => { + panic!("Failed adding source file to parser: {}", err); + } + } + + let tree = match parser.parse(&source, None) { Some(tree) => tree, None => { panic!("Failed parsing source file: {}", source_path.display()); } }; - let wing_parser = Parser::new(&source[..], source_path.to_str().unwrap().to_string()); + let wing_parser = Parser::new(&source, source_path.to_str().unwrap().to_string()); - wing_parser.wingit(&tree.root_node()) + (files, wing_parser.wingit(&tree.root_node())) } pub fn type_check( @@ -211,7 +225,9 @@ pub fn type_check( }], return_type: types.void(), phase: Phase::Independent, - js_override: Some("{((cond) => {if (!cond) throw new Error(`assertion failed: '$args$'`)})($args$)}".to_string()), + js_override: Some( + "{((cond) => {if (!cond) throw new Error(\"assertion failed: $args_text$\")})($args$)}".to_string(), + ), docs: Docs::with_summary("Asserts that a condition is true"), }), scope, @@ -303,7 +319,7 @@ pub fn compile( let out_dir = out_dir.unwrap_or(default_out_dir.as_ref()); // -- PARSING PHASE -- - let scope = parse(&source_path); + let (files, scope) = parse(&source_path); // -- DESUGARING PHASE -- @@ -348,7 +364,7 @@ pub fn compile( return Err(()); } - let mut jsifier = JSifier::new(&types, app_name, &project_dir, true); + let mut jsifier = JSifier::new(&types, &files, app_name, &project_dir, true); jsifier.jsify(&scope); jsifier.emit_files(&out_dir); diff --git a/libs/wingc/src/lsp/sync.rs b/libs/wingc/src/lsp/sync.rs index 695ddf6973d..0c0a6f9d2e0 100644 --- a/libs/wingc/src/lsp/sync.rs +++ b/libs/wingc/src/lsp/sync.rs @@ -7,6 +7,7 @@ use tree_sitter::Tree; use crate::closure_transform::ClosureTransformer; use crate::diagnostic::{get_diagnostics, reset_diagnostics, Diagnostic}; +use crate::files::Files; use crate::fold::Fold; use crate::jsify::JSifier; use crate::parser::Parser; @@ -108,6 +109,16 @@ fn partial_compile(source_file: &str, text: &[u8], jsii_types: &mut TypeSystem) let wing_parser = Parser::new(text, source_file.to_string()); let scope = wing_parser.wingit(&tree.root_node()); + let mut files = Files::new(); + match files.add_file( + source_file, + String::from_utf8(text.to_vec()).expect("Invalid utf-8 sequence"), + ) { + Ok(_) => {} + Err(err) => { + panic!("Failed adding source file to parser: {}", err); + } + } // -- DESUGARING PHASE -- @@ -135,7 +146,7 @@ fn partial_compile(source_file: &str, text: &[u8], jsii_types: &mut TypeSystem) let app_name = source_path.file_stem().expect("Empty filename").to_str().unwrap(); let project_dir = source_path.parent().expect("Empty filename"); - let mut jsifier = JSifier::new(&types, app_name, &project_dir, true); + let mut jsifier = JSifier::new(&types, &files, app_name, &project_dir, true); jsifier.jsify(&scope); return FileData { @@ -150,7 +161,7 @@ fn partial_compile(source_file: &str, text: &[u8], jsii_types: &mut TypeSystem) #[cfg(test)] pub mod test_utils { - use std::str::FromStr; + use std::{fs, str::FromStr}; use uuid::Uuid; use lsp_types::*; @@ -179,8 +190,12 @@ pub mod test_utils { /// ``` /// pub fn load_file_with_contents(content: &str) -> TextDocumentPositionParams { - let filename = format!("file:///{}.w", Uuid::new_v4()); - let uri = Url::from_str(&filename).unwrap(); + let temp_dir = tempfile::tempdir().expect("Failed to create temporary directory"); + let filename = format!("{}.w", Uuid::new_v4()); + let file_path = temp_dir.path().join(&filename); + fs::write(&file_path, content).expect("Failed to write to temporary file"); + let file_uri_string = format!("file:///{}", file_path.to_str().unwrap()); + let uri = Url::from_str(&file_uri_string).unwrap(); on_document_did_open(DidOpenTextDocumentParams { text_document: lsp_types::TextDocumentItem { uri: uri.clone(), diff --git a/libs/wingc/src/parser.rs b/libs/wingc/src/parser.rs index b225f307f1a..f33952948dc 100644 --- a/libs/wingc/src/parser.rs +++ b/libs/wingc/src/parser.rs @@ -170,6 +170,7 @@ impl<'s> Parser<'s> { arg_list: ArgList { pos_args: vec![Expr::new(ExprKind::Literal(Literal::Number(seconds)), span.clone())], named_args: IndexMap::new(), + span: span.clone(), }, }, span.clone(), @@ -1094,6 +1095,7 @@ impl<'s> Parser<'s> { } fn build_arg_list(&self, arg_list_node: &Node, phase: Phase) -> DiagnosticResult { + let span = self.node_span(arg_list_node); let mut pos_args = vec![]; let mut named_args = IndexMap::new(); @@ -1127,7 +1129,11 @@ impl<'s> Parser<'s> { } } - Ok(ArgList { pos_args, named_args }) + Ok(ArgList { + pos_args, + named_args, + span, + }) } fn build_expression(&self, exp_node: &Node, phase: Phase) -> DiagnosticResult { @@ -1141,7 +1147,7 @@ impl<'s> Parser<'s> { let arg_list = if let Ok(args_node) = self.get_child_field(expression_node, "args") { self.build_arg_list(&args_node, phase) } else { - Ok(ArgList::new()) + Ok(ArgList::new(WingSpan::default())) }; let obj_id = if let Some(id_node) = expression_node.child_by_field_name("id") { @@ -1232,13 +1238,11 @@ impl<'s> Parser<'s> { start_from = last_start; } - if interpolation_start != last_start { - parts.push(InterpolatedStringPart::Static( - str::from_utf8(&self.source[start_from..interpolation_start]) - .unwrap() - .into(), - )); - } + parts.push(InterpolatedStringPart::Static( + str::from_utf8(&self.source[start_from..interpolation_start]) + .unwrap() + .into(), + )); parts.push(InterpolatedStringPart::Expr( self.build_expression(&interpolation_node.named_child(0).unwrap(), phase)?, @@ -1249,11 +1253,9 @@ impl<'s> Parser<'s> { start_from = last_end; } - if last_end != end { - parts.push(InterpolatedStringPart::Static( - str::from_utf8(&self.source[last_end..end]).unwrap().into(), - )); - } + parts.push(InterpolatedStringPart::Static( + str::from_utf8(&self.source[last_end..end]).unwrap().into(), + )); Ok(Expr::new( ExprKind::Literal(Literal::InterpolatedString(InterpolatedString { parts })), @@ -1615,6 +1617,7 @@ impl<'s> Parser<'s> { arg_list: ArgList { pos_args: vec![inflight_closure], named_args: IndexMap::new(), + span: type_span.clone(), }, }, span, diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 33e415f2d65..89ca196b4c8 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -634,6 +634,7 @@ pub struct FunctionSignature { /// This string may contain special tokens: /// - `$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 pub js_override: Option, pub docs: Docs, } diff --git a/tools/hangar/__snapshots__/error.ts.snap b/tools/hangar/__snapshots__/error.ts.snap index 20ccc525fad..8008bddb532 100644 --- a/tools/hangar/__snapshots__/error.ts.snap +++ b/tools/hangar/__snapshots__/error.ts.snap @@ -97,8 +97,8 @@ For more information, see https://docs.winglang.io/concepts/resources ../../../examples/tests/error/target/test/repeat_construct_id2.wsim.[REDACTED].tmp/.wing/preflight.js:14 ; - const bucket1 = this.node.root.newAbstract(\\"@winglang/sdk.cloud.Bucket\\",this,\`\${(make_name())}\`); ->> const bucket2 = this.node.root.newAbstract(\\"@winglang/sdk.cloud.Bucket\\",this,\`\${(make_name())}\`); + const bucket1 = this.node.root.newAbstract(\\"@winglang/sdk.cloud.Bucket\\",this,String.raw({ raw: [\\"\\", \\"\\"] }, (make_name()))); +>> const bucket2 = this.node.root.newAbstract(\\"@winglang/sdk.cloud.Bucket\\",this,String.raw({ raw: [\\"\\", \\"\\"] }, (make_name()))); } } @@ -133,12 +133,12 @@ Duration `; exports[`utilities.w 1`] = ` -"ERROR: assertion failed: 'false' +"ERROR: assertion failed: false ../../../examples/tests/error/target/test/utilities.wsim.[REDACTED].tmp/.wing/preflight.js:8 constructor(scope, id) { super(scope, id); ->> {((cond) => {if (!cond) throw new Error(\`assertion failed: 'false'\`)})(false)}; +>> {((cond) => {if (!cond) throw new Error(\\"assertion failed: false\\")})(false)}; {console.log(\\"W\\")}; {((msg) => {throw new Error(msg)})(\\"me\\")}; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/delete.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/delete.w_compile_tf-aws.md index 381cc050eef..e0e0b90647b 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/delete.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/delete.w_compile_tf-aws.md @@ -12,10 +12,10 @@ module.exports = function({ api_DELETE }) { async $inflight_init() { } async handle(req) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.method === api_DELETE)'`)})((req.method === api_DELETE))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.query)["all"] === "true")'`)})(((req.query)["all"] === "true"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.query)["page"] === "6")'`)})(((req.query)["page"] === "6"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.path === "/path")'`)})((req.path === "/path"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.method == api_DELETE")})((req.method === api_DELETE))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.query?.get(\"all\") == \"true\"")})(((req.query)["all"] === "true"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.query?.get(\"page\") == \"6\"")})(((req.query)["page"] === "6"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.path == \"/path\"")})((req.path === "/path"))}; return { "status": 200, "body": (req.query)["page"],} @@ -39,15 +39,15 @@ module.exports = function({ api, http_DELETE, http_Util }) { async $inflight_init() { } async handle() { - const url = `${api.url}/path?all=true&page=6`; + const url = String.raw({ raw: ["", "/path?all=true&page=6"] }, api.url); const response = (await http_Util.delete(url)); const fetchResponse = (await http_Util.fetch(url,Object.freeze({"method":http_DELETE}))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.body === "6")'`)})((response.body === "6"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.status === 200)'`)})((response.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.url === url)'`)})((response.url === url))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.body === "6")'`)})((fetchResponse.body === "6"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.status === 200)'`)})((fetchResponse.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.url === url)'`)})((fetchResponse.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.body == \"6\"")})((response.body === "6"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.status == 200")})((response.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.url == url")})((response.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.body == \"6\"")})((fetchResponse.body === "6"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.status == 200")})((fetchResponse.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.url == url")})((fetchResponse.url === url))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/get.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/get.w_compile_tf-aws.md index 4b8d3d0dac5..604e14bce63 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/get.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/get.w_compile_tf-aws.md @@ -12,9 +12,9 @@ module.exports = function({ api_GET, body }) { async $inflight_init() { } async handle(req) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.method === api_GET)'`)})((req.method === api_GET))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.path === "/path")'`)})((req.path === "/path"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.headers)["content-type"] === "application/json")'`)})(((req.headers)["content-type"] === "application/json"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.method == api_GET")})((req.method === api_GET))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.path == \"/path\"")})((req.path === "/path"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.headers?.get(\"content-type\") == \"application/json\"")})(((req.headers)["content-type"] === "application/json"))}; return { "status": 200, "body": body,} @@ -47,15 +47,15 @@ module.exports = function({ api, http_GET, body, http_Util }) { const fetchResponseNoMethod = (await http_Util.fetch(url,{ "headers": Object.freeze({"content-type":"application/json"}),} )); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(getResponse.body === body)'`)})((getResponse.body === body))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(getResponse.status === 200)'`)})((getResponse.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(getResponse.url === url)'`)})((getResponse.url === url))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.body === body)'`)})((fetchResponse.body === body))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.status === 200)'`)})((fetchResponse.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.url === url)'`)})((fetchResponse.url === url))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponseNoMethod.body === body)'`)})((fetchResponseNoMethod.body === body))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponseNoMethod.status === 200)'`)})((fetchResponseNoMethod.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponseNoMethod.url === url)'`)})((fetchResponseNoMethod.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: getResponse.body == body")})((getResponse.body === body))}; + {((cond) => {if (!cond) throw new Error("assertion failed: getResponse.status == 200")})((getResponse.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: getResponse.url == url")})((getResponse.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.body == body")})((fetchResponse.body === body))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.status == 200")})((fetchResponse.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.url == url")})((fetchResponse.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponseNoMethod.body == body")})((fetchResponseNoMethod.body === body))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponseNoMethod.status == 200")})((fetchResponseNoMethod.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponseNoMethod.url == url")})((fetchResponseNoMethod.url === url))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/patch.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/patch.w_compile_tf-aws.md index c3b97b0fc3f..4c6ce56bba9 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/patch.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/patch.w_compile_tf-aws.md @@ -12,11 +12,11 @@ module.exports = function({ api_PATCH, _id, body, std_Json }) { async $inflight_init() { } async handle(req) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.method === api_PATCH)'`)})((req.method === api_PATCH))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.vars)["id"] === _id)'`)})(((req.vars)["id"] === _id))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.path === ("/path/" + _id))'`)})((req.path === ("/path/" + _id)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]))'`)})((req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.headers)["content-type"] === "application/json")'`)})(((req.headers)["content-type"] === "application/json"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.method == api_PATCH")})((req.method === api_PATCH))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.vars?.get(\"id\") == _id")})(((req.vars)["id"] === _id))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.path == \"/path/\"+ _id")})((req.path === ("/path/" + _id)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.body == Json.stringify(body)")})((req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.headers?.get(\"content-type\") == \"application/json\"")})(((req.headers)["content-type"] === "application/json"))}; return { "status": 200, "body": (req.vars)["id"],} @@ -40,7 +40,7 @@ module.exports = function({ api, _id, body, http_PATCH, http_Util, std_Json }) { async $inflight_init() { } async handle() { - const url = `${api.url}/path/${_id}`; + const url = String.raw({ raw: ["", "/path/", ""] }, api.url, _id); const response = (await http_Util.patch(url,{ "headers": Object.freeze({"content-type":"application/json"}), "body": ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]),} @@ -50,12 +50,12 @@ module.exports = function({ api, _id, body, http_PATCH, http_Util, std_Json }) { "headers": Object.freeze({"content-type":"application/json"}), "body": ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]),} )); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.body === _id)'`)})((response.body === _id))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.status === 200)'`)})((response.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.url === url)'`)})((response.url === url))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.body === _id)'`)})((fetchResponse.body === _id))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.status === 200)'`)})((fetchResponse.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.url === url)'`)})((fetchResponse.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.body == _id")})((response.body === _id))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.status == 200")})((response.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.url == url")})((response.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.body == _id")})((fetchResponse.body === _id))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.status == 200")})((fetchResponse.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.url == url")})((fetchResponse.url === url))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/post.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/post.w_compile_tf-aws.md index 29fed6775d8..860de43490e 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/post.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/post.w_compile_tf-aws.md @@ -12,10 +12,10 @@ module.exports = function({ api_POST, body, std_Json }) { async $inflight_init() { } async handle(req) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.method === api_POST)'`)})((req.method === api_POST))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.path === "/path")'`)})((req.path === "/path"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]))'`)})((req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.headers)["content-type"] === "application/json")'`)})(((req.headers)["content-type"] === "application/json"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.method == api_POST")})((req.method === api_POST))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.path == \"/path\"")})((req.path === "/path"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.body == Json.stringify(body)")})((req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.headers?.get(\"content-type\") == \"application/json\"")})(((req.headers)["content-type"] === "application/json"))}; return { "status": 200, "body": req.body,} @@ -49,12 +49,12 @@ module.exports = function({ api, body, http_POST, http_Util, std_Json }) { "headers": Object.freeze({"content-type":"application/json"}), "body": ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]),} )); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]))'`)})((response.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.status === 200)'`)})((response.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.url === url)'`)})((response.url === url))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]))'`)})((fetchResponse.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.status === 200)'`)})((fetchResponse.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.url === url)'`)})((fetchResponse.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.body == Json.stringify(body)")})((response.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.status == 200")})((response.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.url == url")})((response.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.body == Json.stringify(body)")})((fetchResponse.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.status == 200")})((fetchResponse.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.url == url")})((fetchResponse.url === url))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/put.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/put.w_compile_tf-aws.md index a7b09fb2d5e..1722c32aa60 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/put.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/put.w_compile_tf-aws.md @@ -12,13 +12,13 @@ module.exports = function({ _id, user, api_PUT, body, std_Json }) { async $inflight_init() { } async handle(req) { - const path = `/path/${_id}/nn/${user}`; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.method === api_PUT)'`)})((req.method === api_PUT))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.vars)["id"] === _id)'`)})(((req.vars)["id"] === _id))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.vars)["user"] === user)'`)})(((req.vars)["user"] === user))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.path === path)'`)})((req.path === path))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]))'`)})((req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((req.headers)["content-type"] === "application/json")'`)})(((req.headers)["content-type"] === "application/json"))}; + const path = String.raw({ raw: ["/path/", "/nn/", ""] }, _id, user); + {((cond) => {if (!cond) throw new Error("assertion failed: req.method == api_PUT")})((req.method === api_PUT))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.vars?.get(\"id\") == _id")})(((req.vars)["id"] === _id))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.vars?.get(\"user\") == user")})(((req.vars)["user"] === user))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.path == path")})((req.path === path))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.body == Json.stringify(body)")})((req.body === ((args) => { return JSON.stringify(args[0], null, args[1]) })([body])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: req.headers?.get(\"content-type\") == \"application/json\"")})(((req.headers)["content-type"] === "application/json"))}; return { "status": 200, "body": (req.vars)["id"],} @@ -42,7 +42,7 @@ module.exports = function({ api, _id, user, body, http_PUT, http_Util, std_Json async $inflight_init() { } async handle() { - const url = `${api.url}/path/${_id}/nn/${user}`; + const url = String.raw({ raw: ["", "/path/", "/nn/", ""] }, api.url, _id, user); const response = (await http_Util.put(url,{ "headers": Object.freeze({"content-type":"application/json"}), "body": ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]),} @@ -52,12 +52,12 @@ module.exports = function({ api, _id, user, body, http_PUT, http_Util, std_Json "headers": Object.freeze({"content-type":"application/json"}), "body": ((args) => { return JSON.stringify(args[0], null, args[1]) })([body]),} )); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.body === _id)'`)})((response.body === _id))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.status === 200)'`)})((response.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(response.url === url)'`)})((response.url === url))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.body === _id)'`)})((fetchResponse.body === _id))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.status === 200)'`)})((fetchResponse.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fetchResponse.url === url)'`)})((fetchResponse.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.body == _id")})((response.body === _id))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.status == 200")})((response.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: response.url == url")})((response.url === url))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.body == _id")})((fetchResponse.body === _id))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.status == 200")})((fetchResponse.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fetchResponse.url == url")})((fetchResponse.url === url))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/add_object.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/add_object.w_compile_tf-aws.md index c2142005d0c..cb8dd03c1b9 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/add_object.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/add_object.w_compile_tf-aws.md @@ -12,9 +12,9 @@ module.exports = function({ b, jsonObj1, std_Json }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.list()).length === 2)'`)})(((await b.list()).length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.getJson("file1.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj1]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.getJson("file1.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj1])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.get("file2.txt")) === "Bar")'`)})(((await b.get("file2.txt")) === "Bar"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.list().length == 2")})(((await b.list()).length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(b.getJson(\"file1.json\")) == Json.stringify(jsonObj1)")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.getJson("file1.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj1])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.get(\"file2.txt\") == \"Bar\"")})(((await b.get("file2.txt")) === "Bar"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/bucket_list.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/bucket_list.w_compile_tf-aws.md index 13ea7d684b9..f834f35986b 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/bucket_list.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/bucket_list.w_compile_tf-aws.md @@ -13,22 +13,22 @@ module.exports = function({ b }) { } async handle() { const jsonObj1 = Object.freeze({"key1":"value1"}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.list()).length === 1)'`)})(((await b.list()).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.list().length == 1")})(((await b.list()).length === 1))}; (await b.putJson("file1.json",jsonObj1)); (await b.put("file2.txt","Bar")); (await b.put("random","Buz")); const objs = (await b.list()); const objs2 = (await b.list("file")); - {((cond) => {if (!cond) throw new Error(`assertion failed: 'objs.includes("file1.json")'`)})(objs.includes("file1.json"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'objs.includes("file2.txt")'`)})(objs.includes("file2.txt"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'objs.includes("file3.txt")'`)})(objs.includes("file3.txt"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'objs.includes("random")'`)})(objs.includes("random"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'objs2.includes("file1.json")'`)})(objs2.includes("file1.json"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'objs2.includes("file2.txt")'`)})(objs2.includes("file2.txt"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'objs2.includes("file3.txt")'`)})(objs2.includes("file3.txt"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!objs2.includes("random"))'`)})((!objs2.includes("random")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(objs.length === 4)'`)})((objs.length === 4))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(objs2.length === 3)'`)})((objs2.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.contains(\"file1.json\")")})(objs.includes("file1.json"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.contains(\"file2.txt\")")})(objs.includes("file2.txt"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.contains(\"file3.txt\")")})(objs.includes("file3.txt"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.contains(\"random\")")})(objs.includes("random"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs2.contains(\"file1.json\")")})(objs2.includes("file1.json"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs2.contains(\"file2.txt\")")})(objs2.includes("file2.txt"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs2.contains(\"file3.txt\")")})(objs2.includes("file3.txt"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !objs2.contains(\"random\")")})((!objs2.includes("random")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.length == 4")})((objs.length === 4))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs2.length == 3")})((objs2.length === 3))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/delete.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/delete.w_compile_tf-aws.md index 74e4362bb38..4f9d13c9dd9 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/delete.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/delete.w_compile_tf-aws.md @@ -16,8 +16,8 @@ module.exports = function({ b }) { const jsonObj1 = Object.freeze({"key1":"value1"}); (await b.putJson("file1.json",jsonObj1)); (await b.delete("file1.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await b.exists("file1.json"))'`)})((await b.exists("file1.json")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await b.exists("file2.txt"))'`)})((await b.exists("file2.txt")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.exists(\"file1.json\")")})((await b.exists("file1.json")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.exists(\"file2.txt\")")})((await b.exists("file2.txt")))}; (await b.delete("file1.json",Object.freeze({"mustExist":true}))); try { (await b.delete("file1.json",Object.freeze({"mustExist":true}))); @@ -26,10 +26,10 @@ module.exports = function({ b }) { const e = $error_e.message; error = e; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(error === "Object does not exist (key=file1.json).")'`)})((error === "Object does not exist (key=file1.json)."))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await b.exists("file2.txt"))'`)})((await b.exists("file2.txt")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: error == \"Object does not exist (key=file1.json).\"")})((error === "Object does not exist (key=file1.json)."))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.exists(\"file2.txt\")")})((await b.exists("file2.txt")))}; (await b.delete("file2.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!(await b.exists("file2.txt")))'`)})((!(await b.exists("file2.txt"))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !b.exists(\"file2.txt\")")})((!(await b.exists("file2.txt"))))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.w_compile_tf-aws.md index e7af1f036b4..a69a5e4f4c9 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ table, idsCounter }) { async $inflight_init() { } async handle(key, operation, source) { - (await table.insert(`${(await idsCounter.inc())}`,Object.freeze({"key":key,"operation":operation,"source":`${source}`}))); + (await table.insert(String.raw({ raw: ["", ""] }, (await idsCounter.inc())),Object.freeze({"key":key,"operation":operation,"source":String.raw({ raw: ["", ""] }, source)}))); } } return $Closure1; @@ -92,7 +92,7 @@ module.exports = function({ logHistory, Source }) { async $inflight_init() { } async handle(key, event) { - (await logHistory(key,`${event}`,Source.onEvent)); + (await logHistory(key,String.raw({ raw: ["", ""] }, event),Source.onEvent)); } } return $Closure5; @@ -143,7 +143,7 @@ module.exports = function({ table }) { return async () => { let count = 0; for (const u of (await table.list())) { - if (((((u)["key"] === opts.key) && ((u)["operation"] === opts.type)) && ((u)["source"] === `${opts.source}`))) { + if (((((u)["key"] === opts.key) && ((u)["operation"] === opts.type)) && ((u)["source"] === String.raw({ raw: ["", ""] }, opts.source)))) { count = (count + 1); } } @@ -174,16 +174,16 @@ module.exports = function({ b, wait, checkHitCount, Source }) { (await b.put("c","1")); (await b.put("b","100")); (await b.delete("c")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "a", type: "CREATE", source: Source.anyEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "a", type: "CREATE", source: Source.anyEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "b", type: "CREATE", source: Source.anyEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "b", type: "CREATE", source: Source.anyEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "c", type: "CREATE", source: Source.anyEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "c", type: "CREATE", source: Source.anyEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "a", type: "CREATE", source: Source.onEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "a", type: "CREATE", source: Source.onEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "b", type: "CREATE", source: Source.onEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "b", type: "CREATE", source: Source.onEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "c", type: "CREATE", source: Source.onEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "c", type: "CREATE", source: Source.onEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "b", type: "UPDATE", source: Source.anyEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "b", type: "UPDATE", source: Source.anyEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "c", type: "DELETE", source: Source.anyEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "c", type: "DELETE", source: Source.anyEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "b", type: "UPDATE", source: Source.onEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "b", type: "UPDATE", source: Source.onEvent, count: 1 })))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait((await checkHitCount({ key: "c", type: "DELETE", source: Source.onEvent, count: 1 }))))'`)})((await wait((await checkHitCount({ key: "c", type: "DELETE", source: Source.onEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"a\", type: \"CREATE\", source: Source.anyEvent, count: 1))")})((await wait((await checkHitCount({ key: "a", type: "CREATE", source: Source.anyEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"b\", type: \"CREATE\", source: Source.anyEvent, count: 1))")})((await wait((await checkHitCount({ key: "b", type: "CREATE", source: Source.anyEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"c\", type: \"CREATE\", source: Source.anyEvent, count: 1))")})((await wait((await checkHitCount({ key: "c", type: "CREATE", source: Source.anyEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"a\", type: \"CREATE\", source: Source.onEvent, count: 1))")})((await wait((await checkHitCount({ key: "a", type: "CREATE", source: Source.onEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"b\", type: \"CREATE\", source: Source.onEvent, count: 1))")})((await wait((await checkHitCount({ key: "b", type: "CREATE", source: Source.onEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"c\", type: \"CREATE\", source: Source.onEvent, count: 1))")})((await wait((await checkHitCount({ key: "c", type: "CREATE", source: Source.onEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"b\", type: \"UPDATE\", source: Source.anyEvent, count: 1))")})((await wait((await checkHitCount({ key: "b", type: "UPDATE", source: Source.anyEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"c\", type: \"DELETE\", source: Source.anyEvent, count: 1))")})((await wait((await checkHitCount({ key: "c", type: "DELETE", source: Source.anyEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"b\", type: \"UPDATE\", source: Source.onEvent, count: 1))")})((await wait((await checkHitCount({ key: "b", type: "UPDATE", source: Source.onEvent, count: 1 })))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wait(checkHitCount(key: \"c\", type: \"DELETE\", source: Source.onEvent, count: 1))")})((await wait((await checkHitCount({ key: "c", type: "DELETE", source: Source.onEvent, count: 1 })))))}; } } return $Closure8; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/exists.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/exists.w_compile_tf-aws.md index a2926e54115..ba6991e56e4 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/exists.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/exists.w_compile_tf-aws.md @@ -13,12 +13,12 @@ module.exports = function({ b }) { } async handle() { (await b.put("test1.txt","Foo")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await b.exists("test1.txt"))'`)})((await b.exists("test1.txt")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!(await b.exists("test2.txt")))'`)})((!(await b.exists("test2.txt"))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.exists(\"test1.txt\")")})((await b.exists("test1.txt")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !b.exists(\"test2.txt\")")})((!(await b.exists("test2.txt"))))}; (await b.put("test2.txt","Bar")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await b.exists("test2.txt"))'`)})((await b.exists("test2.txt")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.exists(\"test2.txt\")")})((await b.exists("test2.txt")))}; (await b.delete("test1.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!(await b.exists("test1.txt")))'`)})((!(await b.exists("test1.txt"))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !b.exists(\"test1.txt\")")})((!(await b.exists("test1.txt"))))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/public_url.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/public_url.w_compile_tf-aws.md index 14ee94ca5bc..5d663a60c58 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/public_url.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/public_url.w_compile_tf-aws.md @@ -15,7 +15,7 @@ module.exports = function({ publicBucket, privateBucket }) { let error = ""; (await publicBucket.put("file1.txt","Foo")); (await privateBucket.put("file2.txt","Bar")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await publicBucket.publicUrl("file1.txt")) !== "")'`)})(((await publicBucket.publicUrl("file1.txt")) !== ""))}; + {((cond) => {if (!cond) throw new Error("assertion failed: publicBucket.publicUrl(\"file1.txt\") != \"\"")})(((await publicBucket.publicUrl("file1.txt")) !== ""))}; try { (await privateBucket.publicUrl("file2.txt")); } @@ -23,7 +23,7 @@ module.exports = function({ publicBucket, privateBucket }) { const e = $error_e.message; error = e; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(error === "Cannot provide public url for a non-public bucket")'`)})((error === "Cannot provide public url for a non-public bucket"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: error == \"Cannot provide public url for a non-public bucket\"")})((error === "Cannot provide public url for a non-public bucket"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put.w_compile_tf-aws.md index 9f2c802d670..e5881bd3f16 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put.w_compile_tf-aws.md @@ -16,15 +16,15 @@ module.exports = function({ b }) { (await b.put("test2.txt","Bar")); const first = (await b.get("test1.txt")); const second = (await b.get("test2.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(first === "Foo")'`)})((first === "Foo"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(second === "Bar")'`)})((second === "Bar"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: first == \"Foo\"")})((first === "Foo"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: second == \"Bar\"")})((second === "Bar"))}; (await b.delete("test1.txt")); const files = (await b.list()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(files.includes("test1.txt") === false)'`)})((files.includes("test1.txt") === false))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(files.includes("test2.txt") === true)'`)})((files.includes("test2.txt") === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: files.contains(\"test1.txt\") == false")})((files.includes("test1.txt") === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: files.contains(\"test2.txt\") == true")})((files.includes("test2.txt") === true))}; (await b.put("test2.txt","Baz")); const third = (await b.get("test2.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(third === "Baz")'`)})((third === "Baz"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: third == \"Baz\"")})((third === "Baz"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put_json.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put_json.w_compile_tf-aws.md index 1efc531af0d..1c5e26a9faa 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put_json.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/put_json.w_compile_tf-aws.md @@ -18,16 +18,16 @@ module.exports = function({ b }) { (await b.putJson("test2.txt",jsonObj2)); const testJson1 = (await b.getJson("test1.txt")); const testJson2 = (await b.getJson("test2.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((testJson1)["test"] === (jsonObj1)["test"])'`)})(((testJson1)["test"] === (jsonObj1)["test"]))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((testJson2)["test"] === (jsonObj2)["test"])'`)})(((testJson2)["test"] === (jsonObj2)["test"]))}; + {((cond) => {if (!cond) throw new Error("assertion failed: testJson1.get(\"test\") == jsonObj1.get(\"test\")")})(((testJson1)["test"] === (jsonObj1)["test"]))}; + {((cond) => {if (!cond) throw new Error("assertion failed: testJson2.get(\"test\") == jsonObj2.get(\"test\")")})(((testJson2)["test"] === (jsonObj2)["test"]))}; const jsonObj3 = Object.freeze({"test":"test3"}); (await b.putJson("test3.txt",jsonObj3)); const testJson3 = (await b.getJson("test3.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((testJson3)["test"] === (jsonObj3)["test"])'`)})(((testJson3)["test"] === (jsonObj3)["test"]))}; + {((cond) => {if (!cond) throw new Error("assertion failed: testJson3.get(\"test\") == jsonObj3.get(\"test\")")})(((testJson3)["test"] === (jsonObj3)["test"]))}; (await b.delete("test1.txt")); const files = (await b.list()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(files.includes("test1.txt") === false)'`)})((files.includes("test1.txt") === false))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(files.includes("test2.txt") === true)'`)})((files.includes("test2.txt") === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: files.contains(\"test1.txt\") == false")})((files.includes("test1.txt") === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: files.contains(\"test2.txt\") == true")})((files.includes("test2.txt") === true))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_delete.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_delete.w_compile_tf-aws.md index 4cdff8ecd82..38bf8116e9a 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_delete.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_delete.w_compile_tf-aws.md @@ -14,15 +14,15 @@ module.exports = function({ b }) { async handle() { const jsonObj2 = Object.freeze({"key2":"value2"}); (await b.put("file1.txt","Foo")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryDelete("file1.txt")) === true)'`)})(((await b.tryDelete("file1.txt")) === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryDelete("file1.txt")) === false)'`)})(((await b.tryDelete("file1.txt")) === false))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryDelete("random")) === false)'`)})(((await b.tryDelete("random")) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryDelete(\"file1.txt\") == true")})(((await b.tryDelete("file1.txt")) === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryDelete(\"file1.txt\") == false")})(((await b.tryDelete("file1.txt")) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryDelete(\"random\") == false")})(((await b.tryDelete("random")) === false))}; (await b.put("file2.txt","Bar")); (await b.putJson("file2.json",jsonObj2)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryDelete("file2.txt")) === true)'`)})(((await b.tryDelete("file2.txt")) === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryDelete("file2.json")) === true)'`)})(((await b.tryDelete("file2.json")) === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryDelete("file2.txt")) === false)'`)})(((await b.tryDelete("file2.txt")) === false))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryDelete("file2.json")) === false)'`)})(((await b.tryDelete("file2.json")) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryDelete(\"file2.txt\") == true")})(((await b.tryDelete("file2.txt")) === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryDelete(\"file2.json\") == true")})(((await b.tryDelete("file2.json")) === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryDelete(\"file2.txt\") == false")})(((await b.tryDelete("file2.txt")) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryDelete(\"file2.json\") == false")})(((await b.tryDelete("file2.json")) === false))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get.w_compile_tf-aws.md index c15c7d09457..5e3f1847c37 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get.w_compile_tf-aws.md @@ -13,12 +13,12 @@ module.exports = function({ b }) { } async handle() { (await b.put("test1.txt","Foo")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryGet("test1.txt")) === "Foo")'`)})(((await b.tryGet("test1.txt")) === "Foo"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryGet("test2.txt")) === undefined)'`)})(((await b.tryGet("test2.txt")) === undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryGet(\"test1.txt\") == \"Foo\"")})(((await b.tryGet("test1.txt")) === "Foo"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryGet(\"test2.txt\") == nil")})(((await b.tryGet("test2.txt")) === undefined))}; (await b.put("test2.txt","Bar")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryGet("test2.txt")) === "Bar")'`)})(((await b.tryGet("test2.txt")) === "Bar"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryGet(\"test2.txt\") == \"Bar\"")})(((await b.tryGet("test2.txt")) === "Bar"))}; (await b.delete("test1.txt")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryGet("test1.txt")) === undefined)'`)})(((await b.tryGet("test1.txt")) === undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryGet(\"test1.txt\") == nil")})(((await b.tryGet("test1.txt")) === undefined))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get_json.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get_json.w_compile_tf-aws.md index 97ea8c168eb..931193026ea 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get_json.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/try_get_json.w_compile_tf-aws.md @@ -15,14 +15,14 @@ module.exports = function({ b, std_Json }) { const jsonObj1 = Object.freeze({"key1":"value1"}); const jsonObj2 = Object.freeze({"key2":"value2"}); (await b.putJson("file1.json",jsonObj1)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.tryGetJson("file1.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj1]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.tryGetJson("file1.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj1])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryGetJson("file2.json")) === undefined)'`)})(((await b.tryGetJson("file2.json")) === undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(b.tryGetJson(\"file1.json\")) == Json.stringify(jsonObj1)")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.tryGetJson("file1.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj1])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryGetJson(\"file2.json\") == nil")})(((await b.tryGetJson("file2.json")) === undefined))}; (await b.putJson("file2.json",jsonObj2)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.tryGetJson("file2.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj2]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.tryGetJson("file2.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj2])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(b.tryGetJson(\"file2.json\")) == Json.stringify(jsonObj2)")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await b.tryGetJson("file2.json"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([jsonObj2])))}; (await b.delete("file1.json")); (await b.delete("file2.json")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryGetJson("file1.json")) === undefined)'`)})(((await b.tryGetJson("file1.json")) === undefined))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.tryGetJson("file2.json")) === undefined)'`)})(((await b.tryGetJson("file2.json")) === undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryGetJson(\"file1.json\") == nil")})(((await b.tryGetJson("file1.json")) === undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.tryGetJson(\"file2.json\") == nil")})(((await b.tryGetJson("file2.json")) === undefined))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/dec.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/dec.w_compile_tf-aws.md index b74b5b7ae69..33964c79c7a 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/dec.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/dec.w_compile_tf-aws.md @@ -12,13 +12,13 @@ module.exports = function({ counter }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 1)'`)})(((await counter.peek()) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 1")})(((await counter.peek()) === 1))}; const dec1 = (await counter.dec()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 0)'`)})(((await counter.peek()) === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(dec1 === 1)'`)})((dec1 === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 0")})(((await counter.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: dec1 == 1")})((dec1 === 1))}; const dec2 = (await counter.dec(2)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === (-2))'`)})(((await counter.peek()) === (-2)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(dec2 === 0)'`)})((dec2 === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == -2")})(((await counter.peek()) === (-2)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: dec2 == 0")})((dec2 === 0))}; } } return $Closure1; @@ -39,13 +39,13 @@ module.exports = function({ counter }) { } async handle() { const key = "my-key"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 0)'`)})(((await counter.peek(key)) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 0")})(((await counter.peek(key)) === 0))}; const dec1 = (await counter.dec(undefined,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === (-1))'`)})(((await counter.peek(key)) === (-1)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(dec1 === 0)'`)})((dec1 === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == -1")})(((await counter.peek(key)) === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: dec1 == 0")})((dec1 === 0))}; const dec2 = (await counter.dec(2,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === (-3))'`)})(((await counter.peek(key)) === (-3)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(dec2 === (-1))'`)})((dec2 === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == -3")})(((await counter.peek(key)) === (-3)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: dec2 == -1")})((dec2 === (-1)))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/inc.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/inc.w_compile_tf-aws.md index 20bb9d85e39..c4bea80667e 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/inc.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/inc.w_compile_tf-aws.md @@ -12,18 +12,18 @@ module.exports = function({ counter }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 0)'`)})(((await counter.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 0")})(((await counter.peek()) === 0))}; const r0 = (await counter.inc()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r0 === 0)'`)})((r0 === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 1)'`)})(((await counter.peek()) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r0 == 0")})((r0 === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 1")})(((await counter.peek()) === 1))}; const r1 = (await counter.inc()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r1 === 1)'`)})((r1 === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 2)'`)})(((await counter.peek()) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r1 == 1")})((r1 === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 2")})(((await counter.peek()) === 2))}; const r2 = (await counter.inc(10)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r2 === 2)'`)})((r2 === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 12)'`)})(((await counter.peek()) === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r2 == 2")})((r2 === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 12")})(((await counter.peek()) === 12))}; const r3 = (await counter.inc()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r3 === 12)'`)})((r3 === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r3 == 12")})((r3 === 12))}; } } return $Closure1; @@ -44,18 +44,18 @@ module.exports = function({ counter }) { } async handle() { const key = "my-key"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 0)'`)})(((await counter.peek(key)) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 0")})(((await counter.peek(key)) === 0))}; const r0 = (await counter.inc(undefined,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r0 === 0)'`)})((r0 === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 1)'`)})(((await counter.peek(key)) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r0 == 0")})((r0 === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 1")})(((await counter.peek(key)) === 1))}; const r1 = (await counter.inc(undefined,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r1 === 1)'`)})((r1 === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 2)'`)})(((await counter.peek(key)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r1 == 1")})((r1 === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 2")})(((await counter.peek(key)) === 2))}; const r2 = (await counter.inc(10,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r2 === 2)'`)})((r2 === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 12)'`)})(((await counter.peek(key)) === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r2 == 2")})((r2 === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 12")})(((await counter.peek(key)) === 12))}; const r3 = (await counter.inc(undefined,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r3 === 12)'`)})((r3 === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r3 == 12")})((r3 === 12))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/initial.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/initial.w_compile_tf-aws.md index 27b297f25fe..c11597280bb 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/initial.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/initial.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ counterA }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counterA.peek()) === 0)'`)})(((await counterA.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counterA.peek() == 0")})(((await counterA.peek()) === 0))}; } } return $Closure1; @@ -32,7 +32,7 @@ module.exports = function({ counterB }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counterB.peek()) === 500)'`)})(((await counterB.peek()) === 500))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counterB.peek() == 500")})(((await counterB.peek()) === 500))}; } } return $Closure2; @@ -52,7 +52,7 @@ module.exports = function({ counterC }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counterC.peek()) === (-198))'`)})(((await counterC.peek()) === (-198)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counterC.peek() == -198")})(((await counterC.peek()) === (-198)))}; } } return $Closure3; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/peek.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/peek.w_compile_tf-aws.md index 2241aa56745..3a01e8dd653 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/peek.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/peek.w_compile_tf-aws.md @@ -12,10 +12,10 @@ module.exports = function({ c }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek()) === 0)'`)})(((await c.peek()) === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek()) === 0)'`)})(((await c.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek() == 0")})(((await c.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek() == 0")})(((await c.peek()) === 0))}; (await c.inc()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek()) === 1)'`)})(((await c.peek()) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek() == 1")})(((await c.peek()) === 1))}; } } return $Closure1; @@ -36,10 +36,10 @@ module.exports = function({ c }) { } async handle() { const key = "my-key"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek(key)) === 0)'`)})(((await c.peek(key)) === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek(key)) === 0)'`)})(((await c.peek(key)) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek(key) == 0")})(((await c.peek(key)) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek(key) == 0")})(((await c.peek(key)) === 0))}; (await c.inc(undefined,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek(key)) === 1)'`)})(((await c.peek(key)) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek(key) == 1")})(((await c.peek(key)) === 1))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/set.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/set.w_compile_tf-aws.md index 6313a30d9e1..b15bac42f01 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/set.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/counter/set.w_compile_tf-aws.md @@ -12,15 +12,15 @@ module.exports = function({ counter }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 0)'`)})(((await counter.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 0")})(((await counter.peek()) === 0))}; (await counter.inc()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 1)'`)})(((await counter.peek()) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 1")})(((await counter.peek()) === 1))}; (await counter.inc()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 2)'`)})(((await counter.peek()) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 2")})(((await counter.peek()) === 2))}; (await counter.inc(10)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 12)'`)})(((await counter.peek()) === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 12")})(((await counter.peek()) === 12))}; (await counter.set(88)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek()) === 88)'`)})(((await counter.peek()) === 88))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek() == 88")})(((await counter.peek()) === 88))}; } } return $Closure1; @@ -41,15 +41,15 @@ module.exports = function({ counter }) { } async handle() { const key = "my-key"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 0)'`)})(((await counter.peek(key)) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 0")})(((await counter.peek(key)) === 0))}; (await counter.inc(undefined,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 1)'`)})(((await counter.peek(key)) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 1")})(((await counter.peek(key)) === 1))}; (await counter.inc(undefined,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 2)'`)})(((await counter.peek(key)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 2")})(((await counter.peek(key)) === 2))}; (await counter.inc(10,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 12)'`)})(((await counter.peek(key)) === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 12")})(((await counter.peek(key)) === 12))}; (await counter.set(88,key)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await counter.peek(key)) === 88)'`)})(((await counter.peek(key)) === 88))}; + {((cond) => {if (!cond) throw new Error("assertion failed: counter.peek(key) == 88")})(((await counter.peek(key)) === 88))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/invoke.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/invoke.w_compile_tf-aws.md index 2dccb569497..c9b18ea34d7 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/invoke.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/invoke.w_compile_tf-aws.md @@ -13,8 +13,8 @@ module.exports = function({ util_Util }) { } async handle(input) { const target = (await util_Util.tryEnv("WING_TARGET")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((target) != null)'`)})(((target) != null))}; - return `${input}-response`; + {((cond) => {if (!cond) throw new Error("assertion failed: target?")})(((target) != null))}; + return String.raw({ raw: ["", "-response"] }, input); } } return $Closure1; @@ -35,7 +35,7 @@ module.exports = function({ f }) { } async handle() { const x = (await f.invoke("hello")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === "hello-response")'`)})((x === "hello-response"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == \"hello-response\"")})((x === "hello-response"))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/memory_and_env.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/memory_and_env.w_compile_tf-aws.md index 563aafc3ce4..1f4c9e6a66d 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/memory_and_env.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/function/memory_and_env.w_compile_tf-aws.md @@ -52,11 +52,11 @@ module.exports = function({ c, f1, f2 }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek()) === 0)'`)})(((await c.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek() == 0")})(((await c.peek()) === 0))}; (await f1.invoke("")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek()) === 1)'`)})(((await c.peek()) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek() == 1")})(((await c.peek()) === 1))}; (await f2.invoke("")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.peek()) === 2)'`)})(((await c.peek()) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.peek() == 2")})(((await c.peek()) === 2))}; } } return $Closure3; @@ -524,8 +524,8 @@ class $Root extends $stdlib.std.Resource { "env": Object.freeze({"catName":"Tion"}),} ); (f2.addEnvironment("catAge","2")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((f2.env)["catAge"] === "2")'`)})(((f2.env)["catAge"] === "2"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((f2.env)["catName"] === "Tion")'`)})(((f2.env)["catName"] === "Tion"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: f2.env.get(\"catAge\") == \"2\"")})(((f2.env)["catAge"] === "2"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: f2.env.get(\"catName\") == \"Tion\"")})(((f2.env)["catName"] === "Tion"))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:function with memory and function with env can be invoked",new $Closure3(this,"$Closure3")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/pop.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/pop.w_compile_tf-aws.md index a16217a6780..5ba5dc49797 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/pop.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/pop.w_compile_tf-aws.md @@ -19,9 +19,9 @@ module.exports = function({ q, NIL }) { const first = ((await q.pop()) ?? NIL); const second = ((await q.pop()) ?? NIL); const third = ((await q.pop()) ?? NIL); - {((cond) => {if (!cond) throw new Error(`assertion failed: 'msgs.includes(first)'`)})(msgs.includes(first))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'msgs.includes(second)'`)})(msgs.includes(second))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(third === NIL)'`)})((third === NIL))}; + {((cond) => {if (!cond) throw new Error("assertion failed: msgs.contains(first)")})(msgs.includes(first))}; + {((cond) => {if (!cond) throw new Error("assertion failed: msgs.contains(second)")})(msgs.includes(second))}; + {((cond) => {if (!cond) throw new Error("assertion failed: third == NIL")})((third === NIL))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/purge.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/purge.w_compile_tf-aws.md index cdecc400084..ca3c034cec5 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/purge.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/purge.w_compile_tf-aws.md @@ -27,18 +27,12 @@ module.exports = function({ q, js }) { return false; } ; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait(async () => { - return ((await q.approxSize()) === 3); - } - ))'`)})((await wait(async () => { + {((cond) => {if (!cond) throw new Error("assertion failed: wait(inflight (): bool => { \n return q.approxSize() == 3;\n })")})((await wait(async () => { return ((await q.approxSize()) === 3); } )))}; (await q.purge()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wait(async () => { - return ((await q.approxSize()) === 0); - } - ))'`)})((await wait(async () => { + {((cond) => {if (!cond) throw new Error("assertion failed: wait(inflight (): bool => {\n return q.approxSize() == 0;\n })")})((await wait(async () => { return ((await q.approxSize()) === 0); } )))}; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/set_consumer.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/set_consumer.w_compile_tf-aws.md index 9f74d24aa6c..58b659d556d 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/set_consumer.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/queue/set_consumer.w_compile_tf-aws.md @@ -38,12 +38,12 @@ module.exports = function({ q, predicate, js }) { while ((i < 600)) { i = (i + 1); if ((await predicate.test())) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await predicate.test())'`)})((await predicate.test()))}; + {((cond) => {if (!cond) throw new Error("assertion failed: predicate.test()")})((await predicate.test()))}; return; } (await js.sleep(100)); } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await predicate.test())'`)})((await predicate.test()))}; + {((cond) => {if (!cond) throw new Error("assertion failed: predicate.test()")})((await predicate.test()))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/schedule/on_tick.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/schedule/on_tick.w_compile_tf-aws.md index bb15e501668..9bd29c9c5b7 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/schedule/on_tick.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/schedule/on_tick.w_compile_tf-aws.md @@ -52,11 +52,11 @@ module.exports = function({ c1, c2, Utils }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c1.peek()) === 0)'`)})(((await c1.peek()) === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c2.peek()) === 0)'`)})(((await c2.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c1.peek() == 0")})(((await c1.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c2.peek() == 0")})(((await c2.peek()) === 0))}; (await Utils.sleep(((60 * 1000) * 1.1))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c1.peek()) >= 1)'`)})(((await c1.peek()) >= 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c2.peek()) >= 1)'`)})(((await c2.peek()) >= 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c1.peek() >= 1")})(((await c1.peek()) >= 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c2.peek() >= 1")})(((await c2.peek()) >= 1))}; } } return $Closure3; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/array.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/array.w_compile_tf-aws.md index 3f6704257ff..d94b865714d 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/array.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/array.w_compile_tf-aws.md @@ -12,8 +12,8 @@ module.exports = function({ }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.freeze(["hello"]).length === 1)'`)})((Object.freeze(["hello"]).length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(["hello"].length === 1)'`)})((["hello"].length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: [\"hello\"].length == 1")})((Object.freeze(["hello"]).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MutArray[\"hello\"].length == 1")})((["hello"].length === 1))}; } } return $Closure1; @@ -37,7 +37,7 @@ module.exports = function({ }) { const separator = ","; const joinedString = (await i.join()); const expectedString = (((await i.at(0)) + separator) + (await i.at(1))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(joinedString === expectedString)'`)})((joinedString === expectedString))}; + {((cond) => {if (!cond) throw new Error("assertion failed: joinedString == expectedString")})((joinedString === expectedString))}; } } return $Closure10; @@ -59,8 +59,8 @@ module.exports = function({ }) { async handle() { const o = ["hello", "wing"]; const p = Object.freeze([...(o)]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(o.length === p.length)'`)})((o.length === p.length))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await o.at(0)) === (await p.at(0)))'`)})(((await o.at(0)) === (await p.at(0))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: o.length == p.length")})((o.length === p.length))}; + {((cond) => {if (!cond) throw new Error("assertion failed: o.at(0) == p.at(0)")})(((await o.at(0)) === (await p.at(0))))}; } } return $Closure11; @@ -82,8 +82,8 @@ module.exports = function({ }) { async handle() { const q = Object.freeze(["hello", "wing"]); const r = [...(q)]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(q.length === r.length)'`)})((q.length === r.length))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await q.at(0)) === (await r.at(0)))'`)})(((await q.at(0)) === (await r.at(0))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: q.length == r.length")})((q.length === r.length))}; + {((cond) => {if (!cond) throw new Error("assertion failed: q.at(0) == r.at(0)")})(((await q.at(0)) === (await r.at(0))))}; } } return $Closure12; @@ -105,8 +105,8 @@ module.exports = function({ }) { async handle() { const lastStr = "wing"; const s = ["hello", lastStr, lastStr]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s.lastIndexOf(lastStr) === 2)'`)})((s.lastIndexOf(lastStr) === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s.lastIndexOf("something") === (-1))'`)})((s.lastIndexOf("something") === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s.lastIndexOf(lastStr) == 2")})((s.lastIndexOf(lastStr) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s.lastIndexOf(\"something\") == -1")})((s.lastIndexOf("something") === (-1)))}; } } return $Closure13; @@ -126,8 +126,8 @@ module.exports = function({ }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await Object.freeze(["hello"]).at(0)) === "hello")'`)})(((await Object.freeze(["hello"]).at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await ["hello", "world"].at(1)) === "world")'`)})(((await ["hello", "world"].at(1)) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: [\"hello\"].at(0) == \"hello\"")})(((await Object.freeze(["hello"]).at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MutArray[\"hello\", \"world\"].at(1) == \"world\"")})(((await ["hello", "world"].at(1)) === "world"))}; } } return $Closure2; @@ -148,15 +148,15 @@ module.exports = function({ }) { } async handle() { const a = ["hello"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(a.length === 1)'`)})((a.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.length == 1")})((a.length === 1))}; (await a.push("world")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(a.length === 2)'`)})((a.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await a.at(0)) === "hello")'`)})(((await a.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await a.at(1)) === "world")'`)})(((await a.at(1)) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.length == 2")})((a.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.at(0) == \"hello\"")})(((await a.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.at(1) == \"world\"")})(((await a.at(1)) === "world"))}; const item = (await a.pop()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(item === "world")'`)})((item === "world"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(a.length === 1)'`)})((a.length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await a.at(0)) === "hello")'`)})(((await a.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: item == \"world\"")})((item === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.length == 1")})((a.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.at(0) == \"hello\"")})(((await a.at(0)) === "hello"))}; } } return $Closure3; @@ -177,11 +177,11 @@ module.exports = function({ }) { } async handle() { const b = ["hello"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(b.length === 1)'`)})((b.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.length == 1")})((b.length === 1))}; const d = (await b.concat(["wing"])); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(d.length === 2)'`)})((d.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await d.at(0)) === "hello")'`)})(((await d.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await d.at(1)) === "wing")'`)})(((await d.at(1)) === "wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.length == 2")})((d.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.at(0) == \"hello\"")})(((await d.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.at(1) == \"wing\"")})(((await d.at(1)) === "wing"))}; } } return $Closure4; @@ -202,13 +202,13 @@ module.exports = function({ }) { } async handle() { const array = Object.freeze(["hello"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(array.length === 1)'`)})((array.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: array.length == 1")})((array.length === 1))}; const anotherArray = Object.freeze(["wing"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(anotherArray.length === 1)'`)})((anotherArray.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: anotherArray.length == 1")})((anotherArray.length === 1))}; const mergedArray = (await array.concat(anotherArray)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mergedArray.length === 2)'`)})((mergedArray.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await mergedArray.at(0)) === "hello")'`)})(((await mergedArray.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await mergedArray.at(1)) === "wing")'`)})(((await mergedArray.at(1)) === "wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.length == 2")})((mergedArray.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.at(0) == \"hello\"")})(((await mergedArray.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.at(1) == \"wing\"")})(((await mergedArray.at(1)) === "wing"))}; } } return $Closure5; @@ -229,11 +229,11 @@ module.exports = function({ }) { } async handle() { const e = ["hello", "wing"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'e.includes("wing")'`)})(e.includes("wing"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!e.includes("NotThere"))'`)})((!e.includes("NotThere")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: e.contains(\"wing\")")})(e.includes("wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !e.contains(\"NotThere\")")})((!e.includes("NotThere")))}; const h = Object.freeze(["hello", "wing"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: 'h.includes("wing")'`)})(h.includes("wing"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!h.includes("NotThere"))'`)})((!h.includes("NotThere")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: h.contains(\"wing\")")})(h.includes("wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !h.contains(\"NotThere\")")})((!h.includes("NotThere")))}; } } return $Closure6; @@ -254,8 +254,8 @@ module.exports = function({ }) { } async handle() { const g = ["hello", "wing"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(g.indexOf("wing") === 1)'`)})((g.indexOf("wing") === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(g.indexOf("notThere") === (-1))'`)})((g.indexOf("notThere") === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: g.indexOf(\"wing\") == 1")})((g.indexOf("wing") === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: g.indexOf(\"notThere\") == -1")})((g.indexOf("notThere") === (-1)))}; } } return $Closure7; @@ -276,8 +276,8 @@ module.exports = function({ }) { } async handle() { const g = Object.freeze(["hello", "wing"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(g.indexOf("wing") === 1)'`)})((g.indexOf("wing") === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(g.indexOf("notThere") === (-1))'`)})((g.indexOf("notThere") === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: g.indexOf(\"wing\") == 1")})((g.indexOf("wing") === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: g.indexOf(\"notThere\") == -1")})((g.indexOf("notThere") === (-1)))}; } } return $Closure8; @@ -301,7 +301,7 @@ module.exports = function({ }) { const separator = ";"; const joinedString = (await i.join(separator)); const expectedString = (((await i.at(0)) + separator) + (await i.at(1))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(joinedString === expectedString)'`)})((joinedString === expectedString))}; + {((cond) => {if (!cond) throw new Error("assertion failed: joinedString == expectedString")})((joinedString === expectedString))}; } } return $Closure9; @@ -1774,95 +1774,95 @@ class $Root extends $stdlib.std.Resource { const buckets = Object.freeze([bucket]); const anotherBucket = this.node.root.newAbstract("@winglang/sdk.cloud.Bucket",this,"mySecondBucket"); const anotherBuckets = Object.freeze([anotherBucket]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(buckets.length === 1)'`)})((buckets.length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.freeze([1, 2, 3]).length === 3)'`)})((Object.freeze([1, 2, 3]).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '([1, 2, 3].length === 3)'`)})(([1, 2, 3].length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: buckets.length == 1")})((buckets.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: [1,2,3].length == 3")})((Object.freeze([1, 2, 3]).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MutArray[1,2,3].length == 3")})(([1, 2, 3].length === 3))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:length",new $Closure1(this,"$Closure1")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.freeze(["hello"]).at(0)) === "hello")'`)})(((Object.freeze(["hello"]).at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((["hello", "world"].at(1)) === "world")'`)})(((["hello", "world"].at(1)) === "world"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((buckets.at(0)).node.id === "myBucket")'`)})(((buckets.at(0)).node.id === "myBucket"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: [\"hello\"].at(0) == \"hello\"")})(((Object.freeze(["hello"]).at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MutArray[\"hello\", \"world\"].at(1) == \"world\"")})(((["hello", "world"].at(1)) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: buckets.at(0).node.id == \"myBucket\"")})(((buckets.at(0)).node.id === "myBucket"))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:at()",new $Closure2(this,"$Closure2")); const a = ["hello"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(a.length === 1)'`)})((a.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.length == 1")})((a.length === 1))}; (a.push("world")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(a.length === 2)'`)})((a.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((a.at(0)) === "hello")'`)})(((a.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((a.at(1)) === "world")'`)})(((a.at(1)) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.length == 2")})((a.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.at(0) == \"hello\"")})(((a.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.at(1) == \"world\"")})(((a.at(1)) === "world"))}; const item = (a.pop()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(item === "world")'`)})((item === "world"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(a.length === 1)'`)})((a.length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((a.at(0)) === "hello")'`)})(((a.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: item == \"world\"")})((item === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.length == 1")})((a.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.at(0) == \"hello\"")})(((a.at(0)) === "hello"))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:pushAndPop()",new $Closure3(this,"$Closure3")); const array = Object.freeze(["hello"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(array.length === 1)'`)})((array.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: array.length == 1")})((array.length === 1))}; const mergedArray = (array.concat(Object.freeze(["wing"]))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mergedArray.length === 2)'`)})((mergedArray.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedArray.at(0)) === "hello")'`)})(((mergedArray.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedArray.at(1)) === "wing")'`)})(((mergedArray.at(1)) === "wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.length == 2")})((mergedArray.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.at(0) == \"hello\"")})(((mergedArray.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.at(1) == \"wing\"")})(((mergedArray.at(1)) === "wing"))}; const b = ["hello"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(b.length === 1)'`)})((b.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.length == 1")})((b.length === 1))}; const d = (b.concat(["wing"])); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(d.length === 2)'`)})((d.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((d.at(0)) === "hello")'`)})(((d.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((d.at(1)) === "wing")'`)})(((d.at(1)) === "wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.length == 2")})((d.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.at(0) == \"hello\"")})(((d.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.at(1) == \"wing\"")})(((d.at(1)) === "wing"))}; const mergedBuckets = (buckets.concat(anotherBuckets)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mergedBuckets.length === 2)'`)})((mergedBuckets.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedBuckets.at(0)).node.id === "myBucket")'`)})(((mergedBuckets.at(0)).node.id === "myBucket"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedBuckets.at(1)).node.id === "mySecondBucket")'`)})(((mergedBuckets.at(1)).node.id === "mySecondBucket"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedBuckets.length == 2")})((mergedBuckets.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedBuckets.at(0).node.id == \"myBucket\"")})(((mergedBuckets.at(0)).node.id === "myBucket"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedBuckets.at(1).node.id == \"mySecondBucket\"")})(((mergedBuckets.at(1)).node.id === "mySecondBucket"))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:concatMutArray()",new $Closure4(this,"$Closure4")); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:concatArray()",new $Closure5(this,"$Closure5")); const e = ["hello", "wing"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'e.includes("wing")'`)})(e.includes("wing"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!e.includes("NotThere"))'`)})((!e.includes("NotThere")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'buckets.includes((buckets.at(0)))'`)})(buckets.includes((buckets.at(0))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: e.contains(\"wing\")")})(e.includes("wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !e.contains(\"NotThere\")")})((!e.includes("NotThere")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: buckets.contains(buckets.at(0))")})(buckets.includes((buckets.at(0))))}; const dummyBucket = this.node.root.newAbstract("@winglang/sdk.cloud.Bucket",this,"cloud.Bucket"); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!buckets.includes(dummyBucket))'`)})((!buckets.includes(dummyBucket)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !buckets.contains(dummyBucket)")})((!buckets.includes(dummyBucket)))}; const h = Object.freeze(["hello", "wing"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: 'h.includes("wing")'`)})(h.includes("wing"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!h.includes("NotThere"))'`)})((!h.includes("NotThere")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: h.contains(\"wing\")")})(h.includes("wing"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !h.contains(\"NotThere\")")})((!h.includes("NotThere")))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:contains()",new $Closure6(this,"$Closure6")); const g = ["hello", "wing"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(g.indexOf("wing") === 1)'`)})((g.indexOf("wing") === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(g.indexOf("notThere") === (-1))'`)})((g.indexOf("notThere") === (-1)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(buckets.indexOf(bucket) === 0)'`)})((buckets.indexOf(bucket) === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(buckets.indexOf(dummyBucket) === (-1))'`)})((buckets.indexOf(dummyBucket) === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: g.indexOf(\"wing\") == 1")})((g.indexOf("wing") === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: g.indexOf(\"notThere\") == -1")})((g.indexOf("notThere") === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: buckets.indexOf(bucket) == 0")})((buckets.indexOf(bucket) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: buckets.indexOf(dummyBucket) == -1")})((buckets.indexOf(dummyBucket) === (-1)))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:indexOf()",new $Closure7(this,"$Closure7")); const q = ["hello", "wing"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(q.indexOf("wing") === 1)'`)})((q.indexOf("wing") === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(q.indexOf("notThere") === (-1))'`)})((q.indexOf("notThere") === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: q.indexOf(\"wing\") == 1")})((q.indexOf("wing") === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: q.indexOf(\"notThere\") == -1")})((q.indexOf("notThere") === (-1)))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:indexOfArray()",new $Closure8(this,"$Closure8")); const m = ["hello", "wing"]; const delimeter = ";"; const joinedString = (m.join(delimeter)); const expectedString = (((m.at(0)) + delimeter) + (m.at(1))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(joinedString === expectedString)'`)})((joinedString === expectedString))}; + {((cond) => {if (!cond) throw new Error("assertion failed: joinedString == expectedString")})((joinedString === expectedString))}; const l = ["hello", "wing"]; const separator = ","; const joinedStringWithDefault = (m.join()); const expectedStringWithDefault = (((m.at(0)) + separator) + (m.at(1))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(joinedStringWithDefault === expectedStringWithDefault)'`)})((joinedStringWithDefault === expectedStringWithDefault))}; + {((cond) => {if (!cond) throw new Error("assertion failed: joinedStringWithDefault == expectedStringWithDefault")})((joinedStringWithDefault === expectedStringWithDefault))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:join()",new $Closure9(this,"$Closure9")); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:joinWithDefaultSeparator()",new $Closure10(this,"$Closure10")); const o = ["hello", "wing"]; const p = Object.freeze([...(o)]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(o.length === p.length)'`)})((o.length === p.length))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((o.at(0)) === (p.at(0)))'`)})(((o.at(0)) === (p.at(0))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: o.length == p.length")})((o.length === p.length))}; + {((cond) => {if (!cond) throw new Error("assertion failed: o.at(0) == p.at(0)")})(((o.at(0)) === (p.at(0))))}; const copiedBuckets = [...(buckets)]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(copiedBuckets.length === 1)'`)})((copiedBuckets.length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((copiedBuckets.at(0)).node.id === "myBucket")'`)})(((copiedBuckets.at(0)).node.id === "myBucket"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: copiedBuckets.length == 1")})((copiedBuckets.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: copiedBuckets.at(0).node.id == \"myBucket\"")})(((copiedBuckets.at(0)).node.id === "myBucket"))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:copy()",new $Closure11(this,"$Closure11")); const v = Object.freeze(["hello", "wing"]); const r = [...(v)]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(q.length === r.length)'`)})((q.length === r.length))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((q.at(0)) === (r.at(0)))'`)})(((q.at(0)) === (r.at(0))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: q.length == r.length")})((q.length === r.length))}; + {((cond) => {if (!cond) throw new Error("assertion failed: q.at(0) == r.at(0)")})(((q.at(0)) === (r.at(0))))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:copyMut()",new $Closure12(this,"$Closure12")); const lastStr = "wing"; const s = ["hello", lastStr, lastStr]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s.lastIndexOf(lastStr) === 2)'`)})((s.lastIndexOf(lastStr) === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s.lastIndexOf("something") === (-1))'`)})((s.lastIndexOf("something") === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s.lastIndexOf(lastStr) == 2")})((s.lastIndexOf(lastStr) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s.lastIndexOf(\"something\") == -1")})((s.lastIndexOf("something") === (-1)))}; const multipleBuckets = [bucket, bucket, anotherBucket]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(multipleBuckets.lastIndexOf(bucket) === 1)'`)})((multipleBuckets.lastIndexOf(bucket) === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(multipleBuckets.lastIndexOf(dummyBucket) === (-1))'`)})((multipleBuckets.lastIndexOf(dummyBucket) === (-1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: multipleBuckets.lastIndexOf(bucket) == 1")})((multipleBuckets.lastIndexOf(bucket) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: multipleBuckets.lastIndexOf(dummyBucket) == -1")})((multipleBuckets.lastIndexOf(dummyBucket) === (-1)))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:lastIndexOf()",new $Closure13(this,"$Closure13")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/bool.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/bool.w_compile_tf-aws.md index 08a28baec53..862bbd1c04a 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/bool.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/bool.w_compile_tf-aws.md @@ -43,7 +43,7 @@ class $Root extends $stdlib.std.Resource { constructor(scope, id) { super(scope, id); const t = (std.Boolean.fromJson((JSON.parse("true")))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(t === true)'`)})((t === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: t == true")})((t === true))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/duration.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/duration.w_compile_tf-aws.md index 0e4c3a5bf50..87944665de3 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/duration.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/duration.w_compile_tf-aws.md @@ -12,26 +12,26 @@ module.exports = function({ std_Duration }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(0.012)).seconds === (12 / 1000))'`)})(((await std_Duration.fromSeconds(0.012)).seconds === (12 / 1000)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(12)).seconds === 12)'`)})(((await std_Duration.fromSeconds(12)).seconds === 12))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(720)).seconds === (12 * 60))'`)})(((await std_Duration.fromSeconds(720)).seconds === (12 * 60)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(43200)).seconds === ((12 * 60) * 60))'`)})(((await std_Duration.fromSeconds(43200)).seconds === ((12 * 60) * 60)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(1036800)).seconds === (((12 * 60) * 60) * 24))'`)})(((await std_Duration.fromSeconds(1036800)).seconds === (((12 * 60) * 60) * 24)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(31536000)).seconds === (((((12 * 60) * 60) * 24) * 365) / 12))'`)})(((await std_Duration.fromSeconds(31536000)).seconds === (((((12 * 60) * 60) * 24) * 365) / 12)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(378432000)).seconds === ((((12 * 60) * 60) * 24) * 365))'`)})(((await std_Duration.fromSeconds(378432000)).seconds === ((((12 * 60) * 60) * 24) * 365)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromMilliseconds(10)).seconds === (await std_Duration.fromSeconds(0.01)).seconds)'`)})(((await std_Duration.fromMilliseconds(10)).seconds === (await std_Duration.fromSeconds(0.01)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromMinutes(10)).seconds === (await std_Duration.fromSeconds(600)).seconds)'`)})(((await std_Duration.fromMinutes(10)).seconds === (await std_Duration.fromSeconds(600)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(10)).seconds === (await std_Duration.fromSeconds(10)).seconds)'`)})(((await std_Duration.fromSeconds(10)).seconds === (await std_Duration.fromSeconds(10)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromHours(10)).seconds === (await std_Duration.fromSeconds(36000)).seconds)'`)})(((await std_Duration.fromHours(10)).seconds === (await std_Duration.fromSeconds(36000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromDays(10)).seconds === (await std_Duration.fromSeconds(864000)).seconds)'`)})(((await std_Duration.fromDays(10)).seconds === (await std_Duration.fromSeconds(864000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromMonths(10)).seconds === (await std_Duration.fromSeconds(26280000)).seconds)'`)})(((await std_Duration.fromMonths(10)).seconds === (await std_Duration.fromSeconds(26280000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromYears(10)).seconds === (await std_Duration.fromSeconds(315360000)).seconds)'`)})(((await std_Duration.fromYears(10)).seconds === (await std_Duration.fromSeconds(315360000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(1)).milliseconds === 1000)'`)})(((await std_Duration.fromSeconds(1)).milliseconds === 1000))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(1)).minutes === (1 / 60))'`)})(((await std_Duration.fromSeconds(1)).minutes === (1 / 60)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(1)).hours === (1 / (60 * 60)))'`)})(((await std_Duration.fromSeconds(1)).hours === (1 / (60 * 60))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(1)).days === (1 / ((60 * 60) * 24)))'`)})(((await std_Duration.fromSeconds(1)).days === (1 / ((60 * 60) * 24))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(1)).months === (1 / ((((60 * 60) * 24) * 365) / 12)))'`)})(((await std_Duration.fromSeconds(1)).months === (1 / ((((60 * 60) * 24) * 365) / 12))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await std_Duration.fromSeconds(1)).years === (1 / (((60 * 60) * 24) * 365)))'`)})(((await std_Duration.fromSeconds(1)).years === (1 / (((60 * 60) * 24) * 365))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12ms.seconds == 12 / 1000")})(((await std_Duration.fromSeconds(0.012)).seconds === (12 / 1000)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12s.seconds == 12")})(((await std_Duration.fromSeconds(12)).seconds === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12m.seconds == 12 * 60")})(((await std_Duration.fromSeconds(720)).seconds === (12 * 60)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12h.seconds == 12 * 60 * 60")})(((await std_Duration.fromSeconds(43200)).seconds === ((12 * 60) * 60)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12d.seconds == 12 * 60 * 60 * 24")})(((await std_Duration.fromSeconds(1036800)).seconds === (((12 * 60) * 60) * 24)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12mo.seconds == (12 * 60 * 60 * 24 * 365) / 12")})(((await std_Duration.fromSeconds(31536000)).seconds === (((((12 * 60) * 60) * 24) * 365) / 12)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12y.seconds == 12 * 60 * 60 * 24 * 365")})(((await std_Duration.fromSeconds(378432000)).seconds === ((((12 * 60) * 60) * 24) * 365)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromMilliseconds(10).seconds == 10ms.seconds")})(((await std_Duration.fromMilliseconds(10)).seconds === (await std_Duration.fromSeconds(0.01)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromMinutes(10).seconds == 10m.seconds")})(((await std_Duration.fromMinutes(10)).seconds === (await std_Duration.fromSeconds(600)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromSeconds(10).seconds == 10s.seconds")})(((await std_Duration.fromSeconds(10)).seconds === (await std_Duration.fromSeconds(10)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromHours(10).seconds == 10h.seconds")})(((await std_Duration.fromHours(10)).seconds === (await std_Duration.fromSeconds(36000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromDays(10).seconds == 10d.seconds")})(((await std_Duration.fromDays(10)).seconds === (await std_Duration.fromSeconds(864000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromMonths(10).seconds == 10mo.seconds")})(((await std_Duration.fromMonths(10)).seconds === (await std_Duration.fromSeconds(26280000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromYears(10).seconds == 10y.seconds")})(((await std_Duration.fromYears(10)).seconds === (await std_Duration.fromSeconds(315360000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.milliseconds == 1000")})(((await std_Duration.fromSeconds(1)).milliseconds === 1000))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.minutes == 1 / 60")})(((await std_Duration.fromSeconds(1)).minutes === (1 / 60)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.hours == 1 / (60 * 60)")})(((await std_Duration.fromSeconds(1)).hours === (1 / (60 * 60))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.days == 1 / (60 * 60 * 24)")})(((await std_Duration.fromSeconds(1)).days === (1 / ((60 * 60) * 24))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.months == 1 / ((60 * 60 * 24 * 365) / 12)")})(((await std_Duration.fromSeconds(1)).months === (1 / ((((60 * 60) * 24) * 365) / 12))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.years == 1 / (60 * 60 * 24 * 365)")})(((await std_Duration.fromSeconds(1)).years === (1 / (((60 * 60) * 24) * 365))))}; } } return $Closure1; @@ -204,26 +204,26 @@ class $Root extends $stdlib.std.Resource { super._registerBind(host, ops); } } - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(0.012)).seconds === (12 / 1000))'`)})(((std.Duration.fromSeconds(0.012)).seconds === (12 / 1000)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(12)).seconds === 12)'`)})(((std.Duration.fromSeconds(12)).seconds === 12))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(720)).seconds === (12 * 60))'`)})(((std.Duration.fromSeconds(720)).seconds === (12 * 60)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(43200)).seconds === ((12 * 60) * 60))'`)})(((std.Duration.fromSeconds(43200)).seconds === ((12 * 60) * 60)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(1036800)).seconds === (((12 * 60) * 60) * 24))'`)})(((std.Duration.fromSeconds(1036800)).seconds === (((12 * 60) * 60) * 24)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(31536000)).seconds === (((((12 * 60) * 60) * 24) * 365) / 12))'`)})(((std.Duration.fromSeconds(31536000)).seconds === (((((12 * 60) * 60) * 24) * 365) / 12)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(378432000)).seconds === ((((12 * 60) * 60) * 24) * 365))'`)})(((std.Duration.fromSeconds(378432000)).seconds === ((((12 * 60) * 60) * 24) * 365)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromMilliseconds(10)).seconds === (std.Duration.fromSeconds(0.01)).seconds)'`)})(((std.Duration.fromMilliseconds(10)).seconds === (std.Duration.fromSeconds(0.01)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromMinutes(10)).seconds === (std.Duration.fromSeconds(600)).seconds)'`)})(((std.Duration.fromMinutes(10)).seconds === (std.Duration.fromSeconds(600)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(10)).seconds === (std.Duration.fromSeconds(10)).seconds)'`)})(((std.Duration.fromSeconds(10)).seconds === (std.Duration.fromSeconds(10)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromHours(10)).seconds === (std.Duration.fromSeconds(36000)).seconds)'`)})(((std.Duration.fromHours(10)).seconds === (std.Duration.fromSeconds(36000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromDays(10)).seconds === (std.Duration.fromSeconds(864000)).seconds)'`)})(((std.Duration.fromDays(10)).seconds === (std.Duration.fromSeconds(864000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromMonths(10)).seconds === (std.Duration.fromSeconds(26280000)).seconds)'`)})(((std.Duration.fromMonths(10)).seconds === (std.Duration.fromSeconds(26280000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromYears(10)).seconds === (std.Duration.fromSeconds(315360000)).seconds)'`)})(((std.Duration.fromYears(10)).seconds === (std.Duration.fromSeconds(315360000)).seconds))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(1)).milliseconds === 1000)'`)})(((std.Duration.fromSeconds(1)).milliseconds === 1000))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(1)).minutes === (1 / 60))'`)})(((std.Duration.fromSeconds(1)).minutes === (1 / 60)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(1)).hours === (1 / (60 * 60)))'`)})(((std.Duration.fromSeconds(1)).hours === (1 / (60 * 60))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(1)).days === (1 / ((60 * 60) * 24)))'`)})(((std.Duration.fromSeconds(1)).days === (1 / ((60 * 60) * 24))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(1)).months === (1 / ((((60 * 60) * 24) * 365) / 12)))'`)})(((std.Duration.fromSeconds(1)).months === (1 / ((((60 * 60) * 24) * 365) / 12))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((std.Duration.fromSeconds(1)).years === (1 / (((60 * 60) * 24) * 365)))'`)})(((std.Duration.fromSeconds(1)).years === (1 / (((60 * 60) * 24) * 365))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12ms.seconds == 12 / 1000")})(((std.Duration.fromSeconds(0.012)).seconds === (12 / 1000)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12s.seconds == 12")})(((std.Duration.fromSeconds(12)).seconds === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12m.seconds == 12 * 60")})(((std.Duration.fromSeconds(720)).seconds === (12 * 60)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12h.seconds == 12 * 60 * 60")})(((std.Duration.fromSeconds(43200)).seconds === ((12 * 60) * 60)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12d.seconds == 12 * 60 * 60 * 24")})(((std.Duration.fromSeconds(1036800)).seconds === (((12 * 60) * 60) * 24)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12mo.seconds == (12 * 60 * 60 * 24 * 365) / 12")})(((std.Duration.fromSeconds(31536000)).seconds === (((((12 * 60) * 60) * 24) * 365) / 12)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12y.seconds == 12 * 60 * 60 * 24 * 365")})(((std.Duration.fromSeconds(378432000)).seconds === ((((12 * 60) * 60) * 24) * 365)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromMilliseconds(10).seconds == 10ms.seconds")})(((std.Duration.fromMilliseconds(10)).seconds === (std.Duration.fromSeconds(0.01)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromMinutes(10).seconds == 10m.seconds")})(((std.Duration.fromMinutes(10)).seconds === (std.Duration.fromSeconds(600)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromSeconds(10).seconds == 10s.seconds")})(((std.Duration.fromSeconds(10)).seconds === (std.Duration.fromSeconds(10)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromHours(10).seconds == 10h.seconds")})(((std.Duration.fromHours(10)).seconds === (std.Duration.fromSeconds(36000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromDays(10).seconds == 10d.seconds")})(((std.Duration.fromDays(10)).seconds === (std.Duration.fromSeconds(864000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromMonths(10).seconds == 10mo.seconds")})(((std.Duration.fromMonths(10)).seconds === (std.Duration.fromSeconds(26280000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: duration.fromYears(10).seconds == 10y.seconds")})(((std.Duration.fromYears(10)).seconds === (std.Duration.fromSeconds(315360000)).seconds))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.milliseconds == 1000")})(((std.Duration.fromSeconds(1)).milliseconds === 1000))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.minutes == 1 / 60")})(((std.Duration.fromSeconds(1)).minutes === (1 / 60)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.hours == 1 / (60 * 60)")})(((std.Duration.fromSeconds(1)).hours === (1 / (60 * 60))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.days == 1 / (60 * 60 * 24)")})(((std.Duration.fromSeconds(1)).days === (1 / ((60 * 60) * 24))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.months == 1 / ((60 * 60 * 24 * 365) / 12)")})(((std.Duration.fromSeconds(1)).months === (1 / ((((60 * 60) * 24) * 365) / 12))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 1s.years == 1 / (60 * 60 * 24 * 365)")})(((std.Duration.fromSeconds(1)).years === (1 / (((60 * 60) * 24) * 365))))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:duration",new $Closure1(this,"$Closure1")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/json.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/json.w_compile_tf-aws.md index 5bde71d45d7..7cb8edbf5cd 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/json.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/json.w_compile_tf-aws.md @@ -15,7 +15,7 @@ module.exports = function({ }) { const x = {"a":1}; ((obj, args) => { obj[args[0]] = args[1]; })(x, ["b",2]); const y = (x)["b"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(y === 2)'`)})((y === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y == 2")})((y === 2))}; } } return $Closure1; @@ -39,7 +39,7 @@ module.exports = function({ }) { const a = {"c":3}; ((obj, args) => { obj[args[0]] = args[1]; })(x, [2,a]); const d = (x)[2]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((d)["c"] === 3)'`)})(((d)["c"] === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.get(\"c\") == 3")})(((d)["c"] === 3))}; } } return $Closure2; @@ -313,12 +313,12 @@ class $Root extends $stdlib.std.Resource { const b = {"b":2}; ((obj, args) => { obj[args[0]] = args[1]; })(a, ["c",b]); const c = (a)["c"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((c)["b"] === 2)'`)})(((c)["b"] === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.get(\"b\") == 2")})(((c)["b"] === 2))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:set()",new $Closure1(this,"$Closure1")); const d = {"d":3}; ((obj, args) => { obj[args[0]] = args[1]; })(a, [2,d]); const e = (a)[2]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((e)["d"] === 3)'`)})(((e)["d"] === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: e.get(\"d\") == 3")})(((e)["d"] === 3))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:setAt()",new $Closure2(this,"$Closure2")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.w_compile_tf-aws.md index db2b3f14152..130d211a262 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/map.w_compile_tf-aws.md @@ -44,13 +44,13 @@ class $Root extends $stdlib.std.Resource { super(scope, id); const m = Object.freeze({"hello":123,"world":99}); const mkeys = Object.keys(m); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mkeys.length === 2)'`)})((mkeys.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mkeys.at(0)) === "hello")'`)})(((mkeys.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mkeys.at(1)) === "world")'`)})(((mkeys.at(1)) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mkeys.length == 2")})((mkeys.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mkeys.at(0) == \"hello\"")})(((mkeys.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mkeys.at(1) == \"world\"")})(((mkeys.at(1)) === "world"))}; const mvalues = Object.values(m); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mvalues.length === 2)'`)})((mvalues.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mvalues.at(0)) === 123)'`)})(((mvalues.at(0)) === 123))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mvalues.at(1)) === 99)'`)})(((mvalues.at(1)) === 99))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mvalues.length == 2")})((mvalues.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mvalues.at(0) == 123")})(((mvalues.at(0)) === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mvalues.at(1) == 99")})(((mvalues.at(1)) === 99))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/number.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/number.w_compile_tf-aws.md index 75b443afa28..f5050161bb6 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/number.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/number.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ std_Number }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(123) === 123)'`)})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(123) === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: num.fromJson(Json 123) == 123")})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(123) === 123))}; } } return $Closure1; @@ -32,7 +32,7 @@ module.exports = function({ std_Number }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("888") === 888)'`)})((((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("888") === 888))}; + {((cond) => {if (!cond) throw new Error("assertion failed: num.fromStr(\"888\") == 888")})((((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("888") === 888))}; } } return $Closure2; @@ -305,9 +305,9 @@ class $Root extends $stdlib.std.Resource { super._registerBind(host, ops); } } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(12) === 12)'`)})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(12) === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: num.fromJson(Json 12) == 12")})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(12) === 12))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:fromJson",new $Closure1(this,"$Closure1")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("42") === 42)'`)})((((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("42") === 42))}; + {((cond) => {if (!cond) throw new Error("assertion failed: num.fromStr(\"42\") == 42")})((((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("42") === 42))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:fromStr",new $Closure2(this,"$Closure2")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/string.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/string.w_compile_tf-aws.md index d8a32fbd13f..c27b561f284 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/string.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/std/string.w_compile_tf-aws.md @@ -12,13 +12,13 @@ module.exports = function({ PARSE_ERROR, std_String }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })("World") === "World")'`)})((((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })("World") === "World"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: str.fromJson(Json \"World\") == \"World\"")})((((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })("World") === "World"))}; try { ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })(123); } catch ($error_s) { const s = $error_s.message; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === PARSE_ERROR)'`)})((s === PARSE_ERROR))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == PARSE_ERROR")})((s === PARSE_ERROR))}; } } } @@ -39,8 +39,8 @@ module.exports = function({ }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '("hello".length === 5)'`)})(("hello".length === 5))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("".length === 0)'`)})(("".length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"hello\".length == 5")})(("hello".length === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"\".length == 0")})(("".length === 0))}; } } return $Closure2; @@ -60,7 +60,7 @@ module.exports = function({ }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await "boom".at(0)) === "b")'`)})(((await "boom".at(0)) === "b"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"boom\".at(0) == \"b\"")})(((await "boom".at(0)) === "b"))}; } } return $Closure3; @@ -440,23 +440,23 @@ class $Root extends $stdlib.std.Resource { } catch ($error_actual) { const actual = $error_actual.message; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(actual === expected)'`)})((actual === expected))}; + {((cond) => {if (!cond) throw new Error("assertion failed: actual == expected")})((actual === expected))}; error = true; } - {((cond) => {if (!cond) throw new Error(`assertion failed: 'error'`)})(error)}; + {((cond) => {if (!cond) throw new Error("assertion failed: error")})(error)}; } ; const PARSE_ERROR = "unable to parse number 123 as a string"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })("Hello") === "Hello")'`)})((((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })("Hello") === "Hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: str.fromJson(Json \"Hello\") == \"Hello\"")})((((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })("Hello") === "Hello"))}; (assertThrows(PARSE_ERROR, () => { ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })(123); } )); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:fromJson",new $Closure1(this,"$Closure1")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '("hello".length === 5)'`)})(("hello".length === 5))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("".length === 0)'`)})(("".length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"hello\".length == 5")})(("hello".length === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"\".length == 0")})(("".length === 0))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:length",new $Closure2(this,"$Closure2")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(("boom".at(2)) === "o")'`)})((("boom".at(2)) === "o"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"boom\".at(2) == \"o\"")})((("boom".at(2)) === "o"))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:at()",new $Closure3(this,"$Closure3")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.w_compile_tf-aws.md index 9fc6fb3c8d9..ee0611a582c 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.w_compile_tf-aws.md @@ -12,8 +12,8 @@ module.exports = function({ table, marioInfo, peachInfo, std_Json }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([(await table.get("mario"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([marioInfo]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await table.get("mario"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([marioInfo])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([(await table.get("peach"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([peachInfo]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await table.get("peach"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([peachInfo])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(table.get(\"mario\")) == Json.stringify(marioInfo)")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await table.get("mario"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([marioInfo])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(table.get(\"peach\")) == Json.stringify(peachInfo)")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([(await table.get("peach"))]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([peachInfo])))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.w_compile_tf-aws.md index 4f963fa7109..27ee5879cc7 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.w_compile_tf-aws.md @@ -20,10 +20,10 @@ module.exports = function({ table, std_String }) { } const revital = (unorderded)["revital"]; const eyal = (unorderded)["eyal"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("eyal" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((eyal)["name"]))'`)})(("eyal" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((eyal)["name"])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("male" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((eyal)["gender"]))'`)})(("male" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((eyal)["gender"])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("revital" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((revital)["name"]))'`)})(("revital" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((revital)["name"])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("female" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((revital)["gender"]))'`)})(("female" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((revital)["gender"])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"eyal\" == str.fromJson(eyal.get(\"name\"))")})(("eyal" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((eyal)["name"])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"male\" == str.fromJson(eyal.get(\"gender\"))")})(("male" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((eyal)["gender"])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"revital\" == str.fromJson(revital.get(\"name\"))")})(("revital" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((revital)["name"])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"female\" == str.fromJson(revital.get(\"gender\"))")})(("female" === ((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((revital)["gender"])))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/topic/on_message.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/topic/on_message.w_compile_tf-aws.md index 9a7d31f7939..bbcd551f026 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/topic/on_message.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/topic/on_message.w_compile_tf-aws.md @@ -59,12 +59,12 @@ module.exports = function({ t, predicate, TestHelper }) { while ((i < 600)) { i = (i + 1); if ((await predicate.test())) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await predicate.test())'`)})((await predicate.test()))}; + {((cond) => {if (!cond) throw new Error("assertion failed: predicate.test()")})((await predicate.test()))}; return; } (await TestHelper.sleep(100)); } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await predicate.test())'`)})((await predicate.test()))}; + {((cond) => {if (!cond) throw new Error("assertion failed: predicate.test()")})((await predicate.test()))}; } } return $Closure3; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/env.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/env.w_compile_tf-aws.md index ce1aabec6fb..27dd1301f3d 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/env.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/env.w_compile_tf-aws.md @@ -12,9 +12,9 @@ module.exports = function({ RANDOM, NIL, util_Util }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await util_Util.env("WING_TARGET")).length > 0)'`)})(((await util_Util.env("WING_TARGET")).length > 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: util.env(\"WING_TARGET\").length > 0")})(((await util_Util.env("WING_TARGET")).length > 0))}; const noValue = ((await util_Util.tryEnv(RANDOM)) ?? NIL); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(noValue === NIL)'`)})((noValue === NIL))}; + {((cond) => {if (!cond) throw new Error("assertion failed: noValue == NIL")})((noValue === NIL))}; } } return $Closure1; @@ -198,8 +198,8 @@ class $Root extends $stdlib.std.Resource { } const RANDOM = "RANDOM123412121212kjhkjskdjkj"; const NIL = "<>"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((util.Util.env("PATH")).length > 0)'`)})(((util.Util.env("PATH")).length > 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((util.Util.env("MY_VAR")) === "my value")'`)})(((util.Util.env("MY_VAR")) === "my value"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: util.env(\"PATH\").length > 0")})(((util.Util.env("PATH")).length > 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: util.env(\"MY_VAR\") == \"my value\"")})(((util.Util.env("MY_VAR")) === "my value"))}; let failed = false; try { (util.Util.env(RANDOM)); @@ -207,9 +207,9 @@ class $Root extends $stdlib.std.Resource { catch { failed = true; } - {((cond) => {if (!cond) throw new Error(`assertion failed: 'failed'`)})(failed)}; + {((cond) => {if (!cond) throw new Error("assertion failed: failed")})(failed)}; const no_value = ((util.Util.tryEnv(RANDOM)) ?? NIL); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(no_value === NIL)'`)})((no_value === NIL))}; + {((cond) => {if (!cond) throw new Error("assertion failed: no_value == NIL")})((no_value === NIL))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:use util from inflight",new $Closure1(this,"$Closure1")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/sleep.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/sleep.w_compile_tf-aws.md index 846e54efee8..f864887203c 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/sleep.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/sleep.w_compile_tf-aws.md @@ -16,7 +16,7 @@ module.exports = function({ oneHundredMiliseconds, JSHelper, util_Util }) { (await util_Util.sleep(oneHundredMiliseconds)); const end = (await JSHelper.getTime()); const delta = (end - start); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(delta >= 100)'`)})((delta >= 100))}; + {((cond) => {if (!cond) throw new Error("assertion failed: delta >= 100")})((delta >= 100))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/wait-until.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/wait-until.w_compile_tf-aws.md index 9f20cc60ed7..d57620b3154 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/wait-until.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/util/wait-until.w_compile_tf-aws.md @@ -17,10 +17,10 @@ module.exports = function({ JSHelper, util_Util }) { return true; } ))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((await JSHelper.getTime()) - start) < 1000)'`)})((((await JSHelper.getTime()) - start) < 1000))}; + {((cond) => {if (!cond) throw new Error("assertion failed: JSHelper.getTime() - start < 1000")})((((await JSHelper.getTime()) - start) < 1000))}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } } @@ -46,10 +46,10 @@ module.exports = function({ oneSecond, JSHelper, util_Util }) { return false; } ,{ timeout: oneSecond }))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((await JSHelper.getTime()) - start) > (1 * 1000))'`)})((((await JSHelper.getTime()) - start) > (1 * 1000)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: JSHelper.getTime() - start > 1 * 1000")})((((await JSHelper.getTime()) - start) > (1 * 1000)))}; } } } @@ -78,10 +78,10 @@ module.exports = function({ invokeCounter, oneSecond, JSHelper, util_Util }) { ; if ((await util_Util.waitUntil(returnTrueAfter3Seconds,{ interval: oneSecond }))) { const invocations = (await invokeCounter.peek()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((invocations > 1) && (invocations < 10))'`)})(((invocations > 1) && (invocations < 10)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: invocations > 1 && invocations < 10 ")})(((invocations > 1) && (invocations < 10)))}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } } @@ -109,11 +109,11 @@ module.exports = function({ invokeCounter, oneSecond, fiveSeconds, JSHelper, uti } ; if ((await util_Util.waitUntil(returnFalse,{ interval: oneSecond, timeout: fiveSeconds }))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } else { const invokeCount = (await invokeCounter.peek()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((invokeCount > 3) && (invokeCount < 7))'`)})(((invokeCount > 3) && (invokeCount < 7)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: invokeCount > 3 && invokeCount < 7")})(((invokeCount > 3) && (invokeCount < 7)))}; } } } @@ -140,10 +140,10 @@ module.exports = function({ invokeCounter, util_Util }) { {((msg) => {throw new Error(msg)})("ERROR")}; } )); - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } catch { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await invokeCounter.peek()) === 1)'`)})(((await invokeCounter.peek()) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: invokeCounter.peek() == 1")})(((await invokeCounter.peek()) === 1))}; } } } diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md index c11dd864ff6..cadcbd1be27 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/website/website.w_compile_tf-aws.md @@ -12,9 +12,9 @@ module.exports = function({ w, indexFile, otherFile, config, std_Json, Util }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http(w.url)))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([indexFile]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http(w.url)))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([indexFile])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http((w.url + "/inner-folder/other.html"))))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([otherFile]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http((w.url + "/inner-folder/other.html"))))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([otherFile])))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http((w.url + "/config.json"))))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([((args) => { return JSON.stringify(args[0], null, args[1]) })([config])]))'`)})((((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http((w.url + "/config.json"))))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([((args) => { return JSON.stringify(args[0], null, args[1]) })([config])])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(Util.http(w.url).get(\"body\")) == Json.stringify(indexFile)")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http(w.url)))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([indexFile])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(Util.http(w.url + \"/inner-folder/other.html\").get(\"body\")) == Json.stringify(otherFile)")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http((w.url + "/inner-folder/other.html"))))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([otherFile])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.stringify(Util.http(w.url + \"/config.json\").get(\"body\")) == Json.stringify(Json.stringify(config))")})((((args) => { return JSON.stringify(args[0], null, args[1]) })([((await Util.http((w.url + "/config.json"))))["body"]]) === ((args) => { return JSON.stringify(args[0], null, args[1]) })([((args) => { return JSON.stringify(args[0], null, args[1]) })([config])])))}; } } return $Closure1; @@ -431,7 +431,7 @@ class $Root extends $stdlib.std.Resource { const indexFile = (Util.readFile("./website/website/index.html")); const otherFile = (Util.readFile("./website/website/inner-folder/other.html")); (w.addJson("config.json",config)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(w.path.endsWith("sdk_tests/website/website") || w.path.endsWith("sdk_tests\\website\\website"))'`)})((w.path.endsWith("sdk_tests/website/website") || w.path.endsWith("sdk_tests\\website\\website")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: w.path.endsWith(\"sdk_tests/website/website\") || w.path.endsWith(\"sdk_tests\\\\website\\\\website\")")})((w.path.endsWith("sdk_tests/website/website") || w.path.endsWith("sdk_tests\\website\\website")))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:access files on the website",new $Closure1(this,"$Closure1")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.w_compile_tf-aws.md index 5b6ff6cb523..7b11c67bc16 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.w_compile_tf-aws.md @@ -43,7 +43,7 @@ class $Root extends $stdlib.std.Resource { constructor(scope, id) { super(scope, id); const myfunc = (x) => { - {console.log(`${x}`)}; + {console.log(String.raw({ raw: ["", ""] }, x))}; x = (x + 1); if ((x > 3.14)) { return; @@ -53,7 +53,7 @@ class $Root extends $stdlib.std.Resource { ; (myfunc(1)); (( (x) => { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === 1)'`)})((x === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == 1")})((x === 1))}; } )(1)); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api.w_compile_tf-aws.md index 9c33a8b59b5..055595a7cea 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api.w_compile_tf-aws.md @@ -40,7 +40,7 @@ module.exports = function({ api }) { } async handle() { const url = api.url; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'url.startsWith("http")'`)})(url.startsWith("http"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: url.startsWith(\"http\")")})(url.startsWith("http"))}; } } return $Closure2; @@ -60,7 +60,7 @@ module.exports = function({ __parent_this_3 }) { async $inflight_init() { } async handle(req) { - const text = `${__parent_this_3.api.url}/endpoint2`; + const text = String.raw({ raw: ["", "/endpoint2"] }, __parent_this_3.api.url); return { "status": 200, "body": text,} diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md index 56fd9085244..50427c240fc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md @@ -37,9 +37,9 @@ module.exports = function({ api, http_Util, std_Json }) { } async handle() { const username = "tsuf"; - const res = (await http_Util.get(`${api.url}/users/${username}`)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(res.status === 200)'`)})((res.status === 200))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((JSON.parse((res.body ?? ""))))["user"] === username)'`)})((((JSON.parse((res.body ?? ""))))["user"] === username))}; + const res = (await http_Util.get(String.raw({ raw: ["", "/users/", ""] }, api.url, username))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((res.status === 200))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((JSON.parse((res.body ?? ""))))["user"] === username))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md index 90784ad63ce..00559ce1e38 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md @@ -312,7 +312,7 @@ class $Root extends $stdlib.std.Resource { const handler = new $Closure1(this,"$Closure1"); const testInvalidPath = (path) => { let error = ""; - const expected = `Invalid path ${path}. Url cannot contain \":\", params contains only alpha-numeric chars or \"_\".`; + const expected = String.raw({ raw: ["Invalid path ", ". Url cannot contain \":\", params contains only alpha-numeric chars or \"_\"."] }, path); try { (api.get(path,handler)); } @@ -320,7 +320,7 @@ class $Root extends $stdlib.std.Resource { const e = $error_e.message; error = e; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(error === expected)'`)})((error === expected))}; + {((cond) => {if (!cond) throw new Error("assertion failed: error == expected")})((error === expected))}; } ; const testValidPath = (path) => { @@ -332,7 +332,7 @@ class $Root extends $stdlib.std.Resource { const e = $error_e.message; error = e; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(error === "")'`)})((error === ""))}; + {((cond) => {if (!cond) throw new Error("assertion failed: error == \"\"")})((error === ""))}; } ; (testInvalidPath("/test/{sup:er/:annoying//path}")); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/assert.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/assert.w_compile_tf-aws.md new file mode 100644 index 00000000000..aace693b537 --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/valid/assert.w_compile_tf-aws.md @@ -0,0 +1,246 @@ +# [assert.w](../../../../../examples/tests/valid/assert.w) | compile | tf-aws + +## inflight.$Closure1.js +```js +module.exports = function({ s1, s2 }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async $inflight_init() { + } + async handle() { + {((cond) => {if (!cond) throw new Error("assertion failed: \"\" == \"\"")})(("" === ""))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"\'\" == \"\'\"")})(("'" === "'"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"\\\"\" == \"\\\"\"")})(("\"" === "\""))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"`\" == \"`\"")})(("`" === "`"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"``\" == \"``\"")})(("``" === "``"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"`s1`\" == \"`s1`\"")})(("`s1`" === "`s1`"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1 == s1")})((s1 === s1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}\" == \"${s1}\"")})((String.raw({ raw: ["", ""] }, s1) === String.raw({ raw: ["", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}\" != \"${s2}\"")})((String.raw({ raw: ["", ""] }, s1) !== String.raw({ raw: ["", ""] }, s2)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"a${s1}\" == \"a${s1}\"")})((String.raw({ raw: ["a", ""] }, s1) === String.raw({ raw: ["a", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"a${s1}\" != \"b${s1}\"")})((String.raw({ raw: ["a", ""] }, s1) !== String.raw({ raw: ["b", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}a\" == \"${s1}a\"")})((String.raw({ raw: ["", "a"] }, s1) === String.raw({ raw: ["", "a"] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}a\" != \"${s1}b\"")})((String.raw({ raw: ["", "a"] }, s1) !== String.raw({ raw: ["", "b"] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"`\'${s1}\" == \"`\'${s1}\"")})((String.raw({ raw: ["`'", ""] }, s1) === String.raw({ raw: ["`'", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"a${s1}b${s2}c\" == \"a${s1}b${s2}c\"")})((String.raw({ raw: ["a", "b", "c"] }, s1, s2) === String.raw({ raw: ["a", "b", "c"] }, s1, s2)))}; + } + } + return $Closure1; +} + +``` + +## main.tf.json +```json +{ + "//": { + "metadata": { + "backend": "local", + "stackName": "root", + "version": "0.15.2" + }, + "outputs": { + "root": { + "Default": { + "cloud.TestRunner": { + "TestFunctionArns": "WING_TEST_RUNNER_FUNCTION_ARNS" + } + } + } + } + }, + "output": { + "WING_TEST_RUNNER_FUNCTION_ARNS": { + "value": "[[\"root/Default/Default/test:assert works inflight\",\"${aws_lambda_function.root_testassertworksinflight_Handler_C656B6E3.arn}\"]]" + } + }, + "provider": { + "aws": [ + {} + ] + }, + "resource": { + "aws_iam_role": { + "root_testassertworksinflight_Handler_IamRole_0E843492": { + "//": { + "metadata": { + "path": "root/Default/Default/test:assert works inflight/Handler/IamRole", + "uniqueId": "root_testassertworksinflight_Handler_IamRole_0E843492" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + } + }, + "aws_iam_role_policy": { + "root_testassertworksinflight_Handler_IamRolePolicy_9FDDFC6C": { + "//": { + "metadata": { + "path": "root/Default/Default/test:assert works inflight/Handler/IamRolePolicy", + "uniqueId": "root_testassertworksinflight_Handler_IamRolePolicy_9FDDFC6C" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.root_testassertworksinflight_Handler_IamRole_0E843492.name}" + } + }, + "aws_iam_role_policy_attachment": { + "root_testassertworksinflight_Handler_IamRolePolicyAttachment_4CDBB60D": { + "//": { + "metadata": { + "path": "root/Default/Default/test:assert works inflight/Handler/IamRolePolicyAttachment", + "uniqueId": "root_testassertworksinflight_Handler_IamRolePolicyAttachment_4CDBB60D" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.root_testassertworksinflight_Handler_IamRole_0E843492.name}" + } + }, + "aws_lambda_function": { + "root_testassertworksinflight_Handler_C656B6E3": { + "//": { + "metadata": { + "path": "root/Default/Default/test:assert works inflight/Handler/Default", + "uniqueId": "root_testassertworksinflight_Handler_C656B6E3" + } + }, + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c8a7b0b3", + "WING_TARGET": "tf-aws" + } + }, + "function_name": "Handler-c8a7b0b3", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.root_testassertworksinflight_Handler_IamRole_0E843492.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.root_Code_02F3C603.bucket}", + "s3_key": "${aws_s3_object.root_testassertworksinflight_Handler_S3Object_29324B03.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + } + }, + "aws_s3_bucket": { + "root_Code_02F3C603": { + "//": { + "metadata": { + "path": "root/Default/Code", + "uniqueId": "root_Code_02F3C603" + } + }, + "bucket_prefix": "code-c84a50b1-" + } + }, + "aws_s3_object": { + "root_testassertworksinflight_Handler_S3Object_29324B03": { + "//": { + "metadata": { + "path": "root/Default/Default/test:assert works inflight/Handler/S3Object", + "uniqueId": "root_testassertworksinflight_Handler_S3Object_29324B03" + } + }, + "bucket": "${aws_s3_bucket.root_Code_02F3C603.bucket}", + "key": "", + "source": "" + } + } + } +} +``` + +## preflight.js +```js +const $stdlib = require('@winglang/sdk'); +const $outdir = process.env.WING_SYNTH_DIR ?? "."; +const std = $stdlib.std; +const $wing_is_test = process.env.WING_IS_TEST === "true"; +const $AppBase = $stdlib.core.App.for(process.env.WING_TARGET); +class $Root extends $stdlib.std.Resource { + constructor(scope, id) { + super(scope, id); + class $Closure1 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + this._addInflightOps("handle"); + this.display.hidden = true; + } + static _toInflightType(context) { + const self_client_path = "././inflight.$Closure1.js"; + const s1_client = context._lift(s1); + const s2_client = context._lift(s2); + return $stdlib.core.NodeJsCode.fromInline(` + require("${self_client_path}")({ + s1: ${s1_client}, + s2: ${s2_client}, + }) + `); + } + _toInflight() { + return $stdlib.core.NodeJsCode.fromInline(` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType(this).text}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `); + } + _registerBind(host, ops) { + if (ops.includes("$inflight_init")) { + $Closure1._registerBindObject(s1, host, []); + $Closure1._registerBindObject(s2, host, []); + } + if (ops.includes("handle")) { + $Closure1._registerBindObject(s1, host, []); + $Closure1._registerBindObject(s2, host, []); + } + super._registerBind(host, ops); + } + } + const s1 = "foo"; + const s2 = "bar"; + {((cond) => {if (!cond) throw new Error("assertion failed: \"\" == \"\"")})(("" === ""))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"\'\" == \"\'\"")})(("'" === "'"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"\\\"\" == \"\\\"\"")})(("\"" === "\""))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"`\" == \"`\"")})(("`" === "`"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"``\" == \"``\"")})(("``" === "``"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"`s1`\" == \"`s1`\"")})(("`s1`" === "`s1`"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1 == s1")})((s1 === s1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}\" == \"${s1}\"")})((String.raw({ raw: ["", ""] }, s1) === String.raw({ raw: ["", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}\" != \"${s2}\"")})((String.raw({ raw: ["", ""] }, s1) !== String.raw({ raw: ["", ""] }, s2)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"a${s1}\" == \"a${s1}\"")})((String.raw({ raw: ["a", ""] }, s1) === String.raw({ raw: ["a", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"a${s1}\" != \"b${s1}\"")})((String.raw({ raw: ["a", ""] }, s1) !== String.raw({ raw: ["b", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}a\" == \"${s1}a\"")})((String.raw({ raw: ["", "a"] }, s1) === String.raw({ raw: ["", "a"] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"${s1}a\" != \"${s1}b\"")})((String.raw({ raw: ["", "a"] }, s1) !== String.raw({ raw: ["", "b"] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"`\'${s1}\" == \"`\'${s1}\"")})((String.raw({ raw: ["`'", ""] }, s1) === String.raw({ raw: ["`'", ""] }, s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"a${s1}b${s2}c\" == \"a${s1}b${s2}c\"")})((String.raw({ raw: ["a", "b", "c"] }, s1, s2) === String.raw({ raw: ["a", "b", "c"] }, s1, s2)))}; + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:assert works inflight",new $Closure1(this,"$Closure1")); + } +} +class $App extends $AppBase { + constructor() { + super({ outdir: $outdir, name: "assert", plugins: $plugins, isTestEnvironment: $wing_is_test }); + if ($wing_is_test) { + new $Root(this, "env0"); + const $test_runner = this.testRunner; + const $tests = $test_runner.findTests(); + for (let $i = 1; $i < $tests.length; $i++) { + new $Root(this, "env" + $i); + } + } else { + new $Root(this, "Default"); + } + } +} +new $App().synth(); + +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/assert.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/assert.w_test_sim.md new file mode 100644 index 00000000000..4a5a7201997 --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/valid/assert.w_test_sim.md @@ -0,0 +1,15 @@ +# [assert.w](../../../../../examples/tests/valid/assert.w) | test | sim + +## stdout.log +```log +pass ─ assert.wsim » root/env0/test:assert works inflight + + + + + +Tests 1 passed (1) +Duration + +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.w_compile_tf-aws.md index c52f762eb62..7c1414e14c1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ greeting }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(greeting === "Hello, wingnuts")'`)})((greeting === "Hello, wingnuts"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: greeting == \"Hello, wingnuts\"")})((greeting === "Hello, wingnuts"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii_path.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii_path.w_compile_tf-aws.md index 724d8c155f2..2da87633f0c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii_path.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii_path.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ greeting }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(greeting === "Hello, wingnuts")'`)})((greeting === "Hello, wingnuts"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: greeting == \"Hello, wingnuts\"")})((greeting === "Hello, wingnuts"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.w_compile_tf-aws.md index 3e0ac3948dc..50a7f2cbb5b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.w_compile_tf-aws.md @@ -43,7 +43,7 @@ const projen = require("projen"); class $Root extends $stdlib.std.Resource { constructor(scope, id) { super(scope, id); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(projen.LogLevel.OFF !== projen.LogLevel.VERBOSE)'`)})((projen.LogLevel.OFF !== projen.LogLevel.VERBOSE))}; + {((cond) => {if (!cond) throw new Error("assertion failed: projen.LogLevel.OFF != projen.LogLevel.VERBOSE")})((projen.LogLevel.OFF !== projen.LogLevel.VERBOSE))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bucket_events.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bucket_events.w_compile_tf-aws.md index fd5e65d867d..ab9ad7f67b8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bucket_events.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bucket_events.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ }) { async $inflight_init() { } async handle(key) { - {console.log(`deleted ${key}`)}; + {console.log(String.raw({ raw: ["deleted ", ""] }, key))}; } } return $Closure1; @@ -32,7 +32,7 @@ module.exports = function({ }) { async $inflight_init() { } async handle(key) { - {console.log(`updated ${key}`)}; + {console.log(String.raw({ raw: ["updated ", ""] }, key))}; } } return $Closure2; @@ -52,7 +52,7 @@ module.exports = function({ }) { async $inflight_init() { } async handle(key) { - {console.log(`created ${key}`)}; + {console.log(String.raw({ raw: ["created ", ""] }, key))}; } } return $Closure3; @@ -72,7 +72,7 @@ module.exports = function({ other }) { async $inflight_init() { } async handle(key, event) { - (await other.put(`last_${event}_key`,key)); + (await other.put(String.raw({ raw: ["last_", "_key"] }, event),key)); } } return $Closure4; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.w_compile_tf-aws.md index 257a671f21e..064f923d3d7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.w_compile_tf-aws.md @@ -18,11 +18,11 @@ module.exports = function({ b }) { (await b.put("foo/bar/","text")); (await b.put("foo/bar/baz","text")); const objs = (await b.list()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await objs.at(0)) === "foo")'`)})(((await objs.at(0)) === "foo"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await objs.at(1)) === "foo/")'`)})(((await objs.at(1)) === "foo/"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await objs.at(2)) === "foo/bar")'`)})(((await objs.at(2)) === "foo/bar"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await objs.at(3)) === "foo/bar/")'`)})(((await objs.at(3)) === "foo/bar/"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await objs.at(4)) === "foo/bar/baz")'`)})(((await objs.at(4)) === "foo/bar/baz"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.at(0) == \"foo\"")})(((await objs.at(0)) === "foo"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.at(1) == \"foo/\"")})(((await objs.at(1)) === "foo/"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.at(2) == \"foo/bar\"")})(((await objs.at(2)) === "foo/bar"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.at(3) == \"foo/bar/\"")})(((await objs.at(3)) === "foo/bar/"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: objs.at(4) == \"foo/bar/baz\"")})(((await objs.at(4)) === "foo/bar/baz"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.w_compile_tf-aws.md index ef326dd497b..ad27d4c6e98 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.w_compile_tf-aws.md @@ -32,8 +32,8 @@ module.exports = function({ foo }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await foo.callFn(true)) === 1)'`)})(((await foo.callFn(true)) === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await foo.callFn(false)) === 2)'`)})(((await foo.callFn(false)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.callFn(true) == 1")})(((await foo.callFn(true)) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.callFn(false) == 2")})(((await foo.callFn(false)) === 2))}; (await foo.callFn2()); } } @@ -55,7 +55,7 @@ module.exports = function({ }) { } ; const ret = (await this.inflight2()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(ret === 2)'`)})((ret === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: ret == 2")})((ret === 2))}; } async makeFn(x) { if ((x === true)) { @@ -72,8 +72,8 @@ module.exports = function({ }) { async callFn2() { const one = (await this.inflight1()); const two = (await this.inflight2()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(one === 1)'`)})((one === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(two === 2)'`)})((two === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: one == 1")})((one === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: two == 2")})((two === 2))}; } } return Foo; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.w_compile_tf-aws.md index c481160a4b1..1e967844498 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.w_compile_tf-aws.md @@ -12,15 +12,15 @@ module.exports = function({ arr, mySet, myMap, arrOfMap, j }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await arr.at(0)) === "hello")'`)})(((await arr.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await arr.at(1)) === "world")'`)})(((await arr.at(1)) === "world"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr.length === 2)'`)})((arr.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await mySet.has("my"))'`)})((await mySet.has("my")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mySet.size === 2)'`)})((mySet.size === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("world" in (myMap))'`)})(("world" in (myMap)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(myMap).length === 2)'`)})((Object.keys(myMap).length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("bang" in ((await arrOfMap.at(0))))'`)})(("bang" in ((await arrOfMap.at(0)))))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((j)["b"] === "world")'`)})(((j)["b"] === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr.at(0) == \"hello\"")})(((await arr.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr.at(1) == \"world\"")})(((await arr.at(1)) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr.length == 2")})((arr.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mySet.has(\"my\")")})((await mySet.has("my")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mySet.size == 2")})((mySet.size === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: myMap.has(\"world\")")})(("world" in (myMap)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: myMap.size() == 2")})((Object.keys(myMap).length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arrOfMap.at(0).has(\"bang\")")})(("bang" in ((await arrOfMap.at(0)))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: j.get(\"b\") == \"world\"")})(((j)["b"] === "world"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.w_compile_tf-aws.md index 5f584cae386..e14edef33aa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.w_compile_tf-aws.md @@ -13,8 +13,8 @@ module.exports = function({ b, x }) { } async handle() { (await b.put("file","foo")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.get("file")) === "foo")'`)})(((await b.get("file")) === "foo"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(12 === x)'`)})((12 === x))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.get(\"file\") == \"foo\"")})(((await b.get("file")) === "foo"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 12 == x")})((12 === x))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.w_compile_tf-aws.md index 2c52fdcda36..c8c6287b9ac 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.w_compile_tf-aws.md @@ -12,10 +12,10 @@ module.exports = function({ a, s, m, aCloned }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(a.length === 1)'`)})((a.length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s.size === 1)'`)})((s.size === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m).length === 1)'`)})((Object.keys(m).length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(aCloned.length === 1)'`)})((aCloned.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.length == 1")})((a.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s.size == 1")})((s.size === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m.size() == 1")})((Object.keys(m).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: aCloned.length == 1")})((aCloned.length === 1))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.w_compile_tf-aws.md index 77f1be2598f..9e9cfd715e1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.w_compile_tf-aws.md @@ -14,8 +14,8 @@ module.exports = function({ myStr, myNum, mySecondBool, myBool, myDur }) { async handle(s) { {console.log(myStr)}; const n = myNum; - {console.log(`${n}`)}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mySecondBool === false)'`)})((mySecondBool === false))}; + {console.log(String.raw({ raw: ["", ""] }, n))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mySecondBool == false")})((mySecondBool === false))}; if (myBool) { {console.log("bool=true")}; } @@ -25,8 +25,8 @@ module.exports = function({ myStr, myNum, mySecondBool, myBool, myDur }) { const min = myDur.minutes; const sec = myDur.seconds; const hr = myDur.hours; - const split = (await `min=${min} sec=${sec} hr=${hr}`.split(" ")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(split.length === 3)'`)})((split.length === 3))}; + const split = (await String.raw({ raw: ["min=", " sec=", " hr=", ""] }, min, sec, hr).split(" ")); + {((cond) => {if (!cond) throw new Error("assertion failed: split.length == 3")})((split.length === 3))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.w_compile_tf-aws.md index ee6b049b0ca..1f7d2b570d1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.w_compile_tf-aws.md @@ -56,17 +56,11 @@ module.exports = function({ kv, counter, util_Util }) { (await kv.get("k")); (await kv.get("k")); (await kv.get("k2")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await util_Util.waitUntil(async () => { - return ((await counter.peek("k")) === 2); - } - ))'`)})((await util_Util.waitUntil(async () => { + {((cond) => {if (!cond) throw new Error("assertion failed: util.waitUntil((): bool => {\n return counter.peek(\"k\") == 2;\n })")})((await util_Util.waitUntil(async () => { return ((await counter.peek("k")) === 2); } )))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await util_Util.waitUntil(async () => { - return ((await counter.peek("k2")) === 1); - } - ))'`)})((await util_Util.waitUntil(async () => { + {((cond) => {if (!cond) throw new Error("assertion failed: util.waitUntil((): bool => {\n return counter.peek(\"k2\") == 1;\n })")})((await util_Util.waitUntil(async () => { return ((await counter.peek("k2")) === 1); } )))}; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.w_compile_tf-aws.md index 7c2e0a77f41..4cc16593dbb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ x }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === 5)'`)})((x === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == 5")})((x === 5))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.w_compile_tf-aws.md index cf2216a0bf6..7e5164511f4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.w_compile_tf-aws.md @@ -12,9 +12,9 @@ module.exports = function({ data, res, queue }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(data.size === 3)'`)})((data.size === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: data.size == 3")})((data.size === 3))}; (await res.put("file.txt","world")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await res.get("file.txt")) === "world")'`)})(((await res.get("file.txt")) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: res.get(\"file.txt\") == \"world\"")})(((await res.get("file.txt")) === "world"))}; (await queue.push("spirulina")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.w_compile_tf-aws.md index 7073ab4ca05..888ca6de894 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ a }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '("hey" === a.field)'`)})(("hey" === a.field))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"hey\" == a.field")})(("hey" === a.field))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.w_compile_tf-aws.md index 3a1e9855049..7aa0778b16b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.w_compile_tf-aws.md @@ -32,8 +32,8 @@ module.exports = function({ url, api, MyResource }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await MyResource.isValidUrl(url))'`)})((await MyResource.isValidUrl(url)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await MyResource.isValidUrl(api.url))'`)})((await MyResource.isValidUrl(api.url)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MyResource.isValidUrl(url)")})((await MyResource.isValidUrl(url)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MyResource.isValidUrl(api.url)")})((await MyResource.isValidUrl(api.url)))}; } } return $Closure2; @@ -55,8 +55,8 @@ module.exports = function({ }) { return (require("/url_utils.js")["isValidUrl"])(url) } async foo() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await MyResource.isValidUrl(this.url))'`)})((await MyResource.isValidUrl(this.url)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await MyResource.isValidUrl(this.api.url))'`)})((await MyResource.isValidUrl(this.api.url)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MyResource.isValidUrl(this.url)")})((await MyResource.isValidUrl(this.url)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: MyResource.isValidUrl(this.api.url)")})((await MyResource.isValidUrl(this.api.url)))}; } } return MyResource; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/class.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/class.w_compile_tf-aws.md index 2e442249f03..e9a6443e57e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/class.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/class.w_compile_tf-aws.md @@ -12,10 +12,10 @@ module.exports = function({ c5 }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(c5.x === 123)'`)})((c5.x === 123))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(c5.y === 321)'`)})((c5.y === 321))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c5.x == 123")})((c5.x === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c5.y == 321")})((c5.y === 321))}; (await c5.set(111)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(c5.y === 111)'`)})((c5.y === 111))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c5.y == 111")})((c5.y === 111))}; } } return $Closure1; @@ -35,9 +35,9 @@ module.exports = function({ student }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(student.name === "Tom")'`)})((student.name === "Tom"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(student.major === "MySpace")'`)})((student.major === "MySpace"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(student.hrlyWage === 38)'`)})((student.hrlyWage === 38))}; + {((cond) => {if (!cond) throw new Error("assertion failed: student.name == \"Tom\"")})((student.name === "Tom"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: student.major == \"MySpace\"")})((student.major === "MySpace"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: student.hrlyWage == 38")})((student.hrlyWage === 38))}; } } return $Closure2; @@ -57,7 +57,7 @@ module.exports = function({ ta }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(ta.hrlyWage === 10)'`)})((ta.hrlyWage === 10))}; + {((cond) => {if (!cond) throw new Error("assertion failed: ta.hrlyWage == 10")})((ta.hrlyWage === 10))}; } } return $Closure3; @@ -78,7 +78,7 @@ module.exports = function({ B }) { } async handle() { const b = new B("ba"); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(b.sound === "ba")'`)})((b.sound === "ba"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.sound == \"ba\"")})((b.sound === "ba"))}; } } return $Closure4; @@ -1095,11 +1095,11 @@ class $Root extends $stdlib.std.Resource { } new C1(this,"C1"); const c2 = new C2(this,"C2"); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(c2.x === 1)'`)})((c2.x === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c2.x == 1")})((c2.x === 1))}; const c3 = new C3(this,"C3",1,2); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(c3.x === 1)'`)})((c3.x === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(c3.y === 2)'`)})((c3.y === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((C4.m()) === 1)'`)})(((C4.m()) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c3.x == 1")})((c3.x === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c3.y == 2")})((c3.y === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: C4.m() == 1")})(((C4.m()) === 1))}; const c5 = new C5(this,"C5"); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:access inflight field",new $Closure1(this,"$Closure1")); const student = new PaidStudent(this,"PaidStudent","Tom","MySpace",38); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.w_compile_tf-aws.md index 0c6d0d49744..34bf1615612 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.w_compile_tf-aws.md @@ -74,7 +74,7 @@ class $Root extends $stdlib.std.Resource { class WingResource extends $stdlib.std.Resource { constructor(scope, id, ) { super(scope, id); - {console.log(`my id is ${this.node.id}`)}; + {console.log(String.raw({ raw: ["my id is ", ""] }, this.node.id))}; } static _toInflightType(context) { const self_client_path = "././inflight.WingResource.js"; @@ -111,10 +111,10 @@ class $Root extends $stdlib.std.Resource { const q = this.node.root.new("@cdktf/provider-aws.sqsQueue.SqsQueue",aws.sqsQueue.SqsQueue,this,"aws.sqsQueue.SqsQueue"); const wr = new WingResource(this,"WingResource"); const another_resource = wr; - {console.log(`path of sqs.queue: ${(getPath(q))}`)}; - {console.log(`path of wing resource: ${(getPath(wr))}`)}; + {console.log(String.raw({ raw: ["path of sqs.queue: ", ""] }, (getPath(q))))}; + {console.log(String.raw({ raw: ["path of wing resource: ", ""] }, (getPath(wr))))}; const title = ((getDisplayName(wr)) ?? "no display name"); - {console.log(`display name of wing resource: ${title}`)}; + {console.log(String.raw({ raw: ["display name of wing resource: ", ""] }, title))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/container_types.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/container_types.w_compile_tf-aws.md index 6eabcba47d0..00878deee0b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/container_types.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/container_types.w_compile_tf-aws.md @@ -172,102 +172,102 @@ class $Root extends $stdlib.std.Resource { const bucket2 = this.node.root.newAbstract("@winglang/sdk.cloud.Bucket",this,"bucket2"); const bucket3 = this.node.root.newAbstract("@winglang/sdk.cloud.Bucket",this,"bucket3"); const emptyArray = Object.freeze([]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(emptyArray.length === 0)'`)})((emptyArray.length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: emptyArray.length == 0")})((emptyArray.length === 0))}; const emptyArray2 = []; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(emptyArray2.length === 0)'`)})((emptyArray2.length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: emptyArray2.length == 0")})((emptyArray2.length === 0))}; const arr1 = Object.freeze([1, 2, 3]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr1.length === 3)'`)})((arr1.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr1.at(1)) === 2)'`)})(((arr1.at(1)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr1.length == 3")})((arr1.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr1.at(1) == 2")})(((arr1.at(1)) === 2))}; const arr2 = Object.freeze(["1", "2", "3"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr2.length === 3)'`)})((arr2.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr2.at(1)) === "2")'`)})(((arr2.at(1)) === "2"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr2.length == 3")})((arr2.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr2.at(1) == \"2\"")})(((arr2.at(1)) === "2"))}; const arr3 = Object.freeze([1, 2, 3]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr3.length === 3)'`)})((arr3.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr3.at(1)) === 2)'`)})(((arr3.at(1)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr3.length == 3")})((arr3.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr3.at(1) == 2")})(((arr3.at(1)) === 2))}; const arr4 = Object.freeze([1, 2, 3]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr4.length === 3)'`)})((arr4.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr4.at(1)) === 2)'`)})(((arr4.at(1)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr4.length == 3")})((arr4.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr4.at(1) == 2")})(((arr4.at(1)) === 2))}; const arr5 = Object.freeze([bucket1, bucket2, bucket3]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr5.length === 3)'`)})((arr5.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr5.at(1)) === bucket2)'`)})(((arr5.at(1)) === bucket2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr5.length == 3")})((arr5.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr5.at(1) == bucket2")})(((arr5.at(1)) === bucket2))}; const arr6 = Object.freeze([bucket1, bucket2, bucket3]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr6.length === 3)'`)})((arr6.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr6.at(1)) === bucket2)'`)})(((arr6.at(1)) === bucket2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr6.length == 3")})((arr6.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr6.at(1) == bucket2")})(((arr6.at(1)) === bucket2))}; const arr7 = arr4; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr7.length === 3)'`)})((arr7.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr7.at(1)) === 2)'`)})(((arr7.at(1)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr7.length == 3")})((arr7.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr7.at(1) == 2")})(((arr7.at(1)) === 2))}; const emptyMap = Object.freeze({}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(emptyMap).length === 0)'`)})((Object.keys(emptyMap).length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: emptyMap.size() == 0")})((Object.keys(emptyMap).length === 0))}; const emptyMap2 = {}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(emptyMap2).length === 0)'`)})((Object.keys(emptyMap2).length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: emptyMap2.size() == 0")})((Object.keys(emptyMap2).length === 0))}; const m1 = Object.freeze({"a":1,"b":2,"c":3}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m1).length === 3)'`)})((Object.keys(m1).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m1)["b"] === 2)'`)})(((m1)["b"] === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m1.size() == 3")})((Object.keys(m1).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m1.get(\"b\") == 2")})(((m1)["b"] === 2))}; const m2 = Object.freeze({"a":1,"b":2,"c":3}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m2).length === 3)'`)})((Object.keys(m2).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m2)["b"] === 2)'`)})(((m2)["b"] === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m2.size() == 3")})((Object.keys(m2).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m2.get(\"b\") == 2")})(((m2)["b"] === 2))}; const m3 = Object.freeze({"a":1,"b":2,"c":3}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m3).length === 3)'`)})((Object.keys(m3).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m3)["b"] === 2)'`)})(((m3)["b"] === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m3.size() == 3")})((Object.keys(m3).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m3.get(\"b\") == 2")})(((m3)["b"] === 2))}; const m4 = Object.freeze({"a":1,"b":2,"c":3}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m4).length === 3)'`)})((Object.keys(m4).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m4)["b"] === 2)'`)})(((m4)["b"] === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m4.size() == 3")})((Object.keys(m4).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m4.get(\"b\") == 2")})(((m4)["b"] === 2))}; const m5 = Object.freeze({"a":bucket1,"b":bucket2,"c":bucket3}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m5).length === 3)'`)})((Object.keys(m5).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m5)["b"] === bucket2)'`)})(((m5)["b"] === bucket2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m5.size() == 3")})((Object.keys(m5).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m5.get(\"b\") == bucket2")})(((m5)["b"] === bucket2))}; const m6 = Object.freeze({"a":bucket1,"b":bucket2,"c":bucket3}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m6).length === 3)'`)})((Object.keys(m6).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m6)["b"] === bucket2)'`)})(((m6)["b"] === bucket2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m6.size() == 3")})((Object.keys(m6).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m6.get(\"b\") == bucket2")})(((m6)["b"] === bucket2))}; const m7 = m1; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m7).length === 3)'`)})((Object.keys(m7).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m7)["b"] === 2)'`)})(((m7)["b"] === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("b" in (m7))'`)})(("b" in (m7)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(("boom" in (m4)) === false)'`)})((("boom" in (m4)) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m7.size() == 3")})((Object.keys(m7).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m7.get(\"b\") == 2")})(((m7)["b"] === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m7.has(\"b\")")})(("b" in (m7)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m4.has(\"boom\") == false")})((("boom" in (m4)) === false))}; const m8 = Object.freeze({"a":"a1","b":"b1","c":"c1"}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.keys(m8).at(0)) === "a")'`)})(((Object.keys(m8).at(0)) === "a"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.keys(m8).at(1)) === "b")'`)})(((Object.keys(m8).at(1)) === "b"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.keys(m8).at(2)) === "c")'`)})(((Object.keys(m8).at(2)) === "c"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.values(m8).at(0)) === "a1")'`)})(((Object.values(m8).at(0)) === "a1"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.values(m8).at(1)) === "b1")'`)})(((Object.values(m8).at(1)) === "b1"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.values(m8).at(2)) === "c1")'`)})(((Object.values(m8).at(2)) === "c1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m8.keys().at(0) == \"a\"")})(((Object.keys(m8).at(0)) === "a"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m8.keys().at(1) == \"b\"")})(((Object.keys(m8).at(1)) === "b"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m8.keys().at(2) == \"c\"")})(((Object.keys(m8).at(2)) === "c"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m8.values().at(0) == \"a1\"")})(((Object.values(m8).at(0)) === "a1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m8.values().at(1) == \"b1\"")})(((Object.values(m8).at(1)) === "b1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m8.values().at(2) == \"c1\"")})(((Object.values(m8).at(2)) === "c1"))}; for (const val of Object.keys(m8)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!val.endsWith("1"))'`)})((!val.endsWith("1")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !val.endsWith(\"1\")")})((!val.endsWith("1")))}; } for (const val of Object.values(m8)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'val.endsWith("1")'`)})(val.endsWith("1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: val.endsWith(\"1\")")})(val.endsWith("1"))}; } const m9 = {"a":"a1","b":"b1","c":"c1"}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.keys(m9).at(0)) === "a")'`)})(((Object.keys(m9).at(0)) === "a"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.keys(m9).at(1)) === "b")'`)})(((Object.keys(m9).at(1)) === "b"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.keys(m9).at(2)) === "c")'`)})(((Object.keys(m9).at(2)) === "c"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.values(m9).at(0)) === "a1")'`)})(((Object.values(m9).at(0)) === "a1"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.values(m9).at(1)) === "b1")'`)})(((Object.values(m9).at(1)) === "b1"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.values(m9).at(2)) === "c1")'`)})(((Object.values(m9).at(2)) === "c1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m9.keys().at(0) == \"a\"")})(((Object.keys(m9).at(0)) === "a"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m9.keys().at(1) == \"b\"")})(((Object.keys(m9).at(1)) === "b"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m9.keys().at(2) == \"c\"")})(((Object.keys(m9).at(2)) === "c"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m9.values().at(0) == \"a1\"")})(((Object.values(m9).at(0)) === "a1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m9.values().at(1) == \"b1\"")})(((Object.values(m9).at(1)) === "b1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m9.values().at(2) == \"c1\"")})(((Object.values(m9).at(2)) === "c1"))}; for (const val of Object.keys(m9)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!val.endsWith("1"))'`)})((!val.endsWith("1")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !val.endsWith(\"1\")")})((!val.endsWith("1")))}; } for (const val of Object.values(m9)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'val.endsWith("1")'`)})(val.endsWith("1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: val.endsWith(\"1\")")})(val.endsWith("1"))}; } const emptySet = Object.freeze(new Set([])); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(emptySet.size === 0)'`)})((emptySet.size === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: emptySet.size == 0")})((emptySet.size === 0))}; const emptySet2 = new Set([]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(emptySet2.size === 0)'`)})((emptySet2.size === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: emptySet2.size == 0")})((emptySet2.size === 0))}; const s2 = Object.freeze(new Set([1, 2, 3])); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s2.size === 3)'`)})((s2.size === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s2.has(1))'`)})((s2.has(1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s2.size == 3")})((s2.size === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s2.has(1)")})((s2.has(1)))}; const s3 = Object.freeze(new Set([1, 2, 3])); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s3.size === 3)'`)})((s3.size === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s3.has(1))'`)})((s3.has(1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s3.size == 3")})((s3.size === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s3.has(1)")})((s3.has(1)))}; const s4 = Object.freeze(new Set([1, 2, 3])); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s4.size === 3)'`)})((s4.size === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s4.has(1))'`)})((s4.has(1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s4.size == 3")})((s4.size === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s4.has(1)")})((s4.has(1)))}; const s6 = Object.freeze(new Set([bucket1, bucket2, bucket3])); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s6.size === 3)'`)})((s6.size === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s6.has(bucket2))'`)})((s6.has(bucket2)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s6.size == 3")})((s6.size === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s6.has(bucket2)")})((s6.has(bucket2)))}; const s7 = s2; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s7.size === 3)'`)})((s7.size === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s7.has(1))'`)})((s7.has(1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s7.size == 3")})((s7.size === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s7.has(1)")})((s7.has(1)))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/doubler.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/doubler.w_compile_tf-aws.md index d7d46f3a99b..9fbf33d3264 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/doubler.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/doubler.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ }) { async $inflight_init() { } async handle(m) { - return `Hello ${m}!`; + return String.raw({ raw: ["Hello ", "!"] }, m); } } return $Closure1; @@ -76,7 +76,7 @@ module.exports = function({ f }) { } async handle() { const result = (await f.invoke("2")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(result === "8")'`)})((result === "8"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: result == \"8\"")})((result === "8"))}; } } return $Closure4; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.w_compile_tf-aws.md index 86cc3e0db9c..1ff9033fd11 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.w_compile_tf-aws.md @@ -50,15 +50,15 @@ class $Root extends $stdlib.std.Resource { const yf = ((-20.22) * xf); const zf = ((xf + yf) - (-0.01)); const fxzy = (5 ** (2 ** 3)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(fxzy === 390625)'`)})((fxzy === 390625))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fxzy == 390625")})((fxzy === 390625))}; const xyzf = Math.trunc(501 / (99 + 1)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(xyzf === 5)'`)})((xyzf === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: xyzf == 5")})((xyzf === 5))}; const xyznf = Math.trunc((-501) / (99 + 1)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(xyznf === (-5))'`)})((xyznf === (-5)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: xyznf == -5")})((xyznf === (-5)))}; const xyznfj = Math.trunc(501.9 / ((-99.1) - 0.91)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(xyznfj === (-5))'`)})((xyznfj === (-5)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: xyznfj == -5")})((xyznfj === (-5)))}; const xynfj = Math.trunc((-501.9) / ((-99.1) - 0.91)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(xynfj === 5)'`)})((xynfj === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: xynfj == 5")})((xynfj === 5))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.w_compile_tf-aws.md index 021a763e06c..982e5f5e8c6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.w_compile_tf-aws.md @@ -45,10 +45,10 @@ class $Root extends $stdlib.std.Resource { const regularString = "str\n\""; const emptyString = ""; const number = 1; - const coolString = `cool \"\${${regularString}}\" test`; - const reallyCoolString = `${number}${emptyString}\n${coolString}\n\${empty_string}${"string-in-string"}!`; - const beginingWithCoolStrings = `${regularString} ${number} <- cool`; - const endingWithCoolStrings = `cool -> ${regularString} ${number}`; + const coolString = String.raw({ raw: ["cool \"\${", "}\" test"] }, regularString); + const reallyCoolString = String.raw({ raw: ["", "", "\n", "\n\${empty_string}", "!"] }, number, emptyString, coolString, "string-in-string"); + const beginingWithCoolStrings = String.raw({ raw: ["", " ", " <- cool"] }, regularString, number); + const endingWithCoolStrings = String.raw({ raw: ["cool -> ", " ", ""] }, regularString, number); } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.w_compile_tf-aws.md index 8d3985a690b..902265fd63f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.w_compile_tf-aws.md @@ -61,10 +61,10 @@ module.exports = function({ }) { return (require("/external_js.js")["print"])(msg) } async call() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await Foo.regexInflight("[a-z]+-\\d+","abc-123"))'`)})((await Foo.regexInflight("[a-z]+-\\d+","abc-123")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Foo.regexInflight(\"[a-z]+-\\\\d+\", \"abc-123\")")})((await Foo.regexInflight("[a-z]+-\\d+","abc-123")))}; const uuid = (await Foo.getUuid()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(uuid.length === 36)'`)})((uuid.length === 36))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await Foo.getData()) === "Cool data!")'`)})(((await Foo.getData()) === "Cool data!"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: uuid.length == 36")})((uuid.length === 36))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Foo.getData() == \"Cool data!\"")})(((await Foo.getData()) === "Cool data!"))}; } } return Foo; @@ -391,8 +391,8 @@ class $Root extends $stdlib.std.Resource { super._registerBind(host, ops); } } - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Foo.getGreeting("Wingding")) === "Hello, Wingding!")'`)})(((Foo.getGreeting("Wingding")) === "Hello, Wingding!"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Foo.v4()).length === 36)'`)})(((Foo.v4()).length === 36))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Foo.getGreeting(\"Wingding\") == \"Hello, Wingding!\"")})(((Foo.getGreeting("Wingding")) === "Hello, Wingding!"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Foo.v4().length == 36")})(((Foo.v4()).length === 36))}; const f = new Foo(this,"Foo"); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:call",new $Closure1(this,"$Closure1")); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:console",new $Closure2(this,"$Closure2")); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.w_compile_tf-aws.md index e178c0aecef..c0e0adbe835 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.w_compile_tf-aws.md @@ -13,7 +13,7 @@ module.exports = function({ counter, bucket }) { } async handle(body) { const next = (await counter.inc()); - const key = `myfile-${"hi"}.txt`; + const key = String.raw({ raw: ["myfile-", ".txt"] }, "hi"); (await bucket.put(key,body)); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.w_compile_tf-aws.md index 04b7e0145a7..90e2b00bc95 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.w_compile_tf-aws.md @@ -13,9 +13,9 @@ module.exports = function({ }) { } async handle(event) { for (const x of ((s,e,i) => { function* iterator(start,end,inclusive) { let i = start; let limit = inclusive ? ((end < start) ? end - 1 : end + 1) : end; while (i < limit) yield i++; while (i > limit) yield i--; }; return iterator(s,e,i); })(0,10,false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 0)'`)})((x <= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x > 10)'`)})((x > 10))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 0")})((x <= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x > 10")})((x > 10))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } } } @@ -242,8 +242,8 @@ class $Root extends $stdlib.std.Resource { const uniqueNumbers = Object.freeze(new Set([1, 2, 3])); for (const word of words) { for (const number of uniqueNumbers) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(number > 0)'`)})((number > 0))}; - {console.log(`${word}: ${number}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: number > 0")})((number > 0))}; + {console.log(String.raw({ raw: ["", ": ", ""] }, word, number))}; } } let i = 0; @@ -252,130 +252,130 @@ class $Root extends $stdlib.std.Resource { let preBreakHits = 0; let postBreakHits = 0; for (const number of uniqueNumbers) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(number > 0)'`)})((number > 0))}; - {console.log(`${word}: ${number}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: number > 0")})((number > 0))}; + {console.log(String.raw({ raw: ["", ": ", ""] }, word, number))}; preBreakHits = (preBreakHits + 1); if ((number === 2)) { break; } postBreakHits = (postBreakHits + 1); } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(preBreakHits === 2)'`)})((preBreakHits === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(postBreakHits === 1)'`)})((postBreakHits === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: preBreakHits == 2")})((preBreakHits === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: postBreakHits == 1")})((postBreakHits === 1))}; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(i === 3)'`)})((i === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: i == 3")})((i === 3))}; let j = 0; for (const word of words) { j = (j + 1); let preContinueHits = 0; let postContinueHits = 0; for (const number of uniqueNumbers) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(number > 0)'`)})((number > 0))}; - {console.log(`${word}: ${number}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: number > 0")})((number > 0))}; + {console.log(String.raw({ raw: ["", ": ", ""] }, word, number))}; preContinueHits = (preContinueHits + 1); if ((number > 0)) { continue; } postContinueHits = (postContinueHits + 1); } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(preContinueHits === 3)'`)})((preContinueHits === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(postContinueHits === 0)'`)})((postContinueHits === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: preContinueHits == 3")})((preContinueHits === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: postContinueHits == 0")})((postContinueHits === 0))}; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(j === 3)'`)})((j === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: j == 3")})((j === 3))}; {console.log("---\nfor x in 0..0 { ... }")}; for (const x of $stdlib.std.Range.of(0, 0, false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } {console.log("there's no value to iterate")}; {console.log("---\nfor x in 0..=0 { ... }")}; for (const x of $stdlib.std.Range.of(0, 0, true)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === 0)'`)})((x === 0))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == 0")})((x === 0))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 0..2 { ... }")}; for (const x of $stdlib.std.Range.of(0, 2, false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= 0)'`)})((x >= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x < 2)'`)})((x < 2))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= 0")})((x >= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x < 2")})((x < 2))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 0..=2 { ... }")}; for (const x of $stdlib.std.Range.of(0, 2, true)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= 0)'`)})((x >= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 2)'`)})((x <= 2))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= 0")})((x >= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 2")})((x <= 2))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 2..0 { ... }")}; for (const x of $stdlib.std.Range.of(2, 0, false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 2)'`)})((x <= 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x > 0)'`)})((x > 0))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 2")})((x <= 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x > 0")})((x > 0))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 2..=0 { ... }")}; for (const x of $stdlib.std.Range.of(2, 0, true)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 2)'`)})((x <= 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= 0)'`)})((x >= 0))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 2")})((x <= 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= 0")})((x >= 0))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 0..-2 { ... }")}; for (const x of $stdlib.std.Range.of(0, (-2), false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 0)'`)})((x <= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x > (-2))'`)})((x > (-2)))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 0")})((x <= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x > -2")})((x > (-2)))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 0..=-2 { ... }")}; for (const x of $stdlib.std.Range.of(0, (-2), true)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 0)'`)})((x <= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x > (-3))'`)})((x > (-3)))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 0")})((x <= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x > -3")})((x > (-3)))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in -2..0 { ... }")}; for (const x of $stdlib.std.Range.of((-2), 0, false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= (-2))'`)})((x >= (-2)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x < 0)'`)})((x < 0))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= -2")})((x >= (-2)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x < 0")})((x < 0))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in -2..=0 { ... }")}; for (const x of $stdlib.std.Range.of((-2), 0, true)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= (-2))'`)})((x >= (-2)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 0)'`)})((x <= 0))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= -2")})((x >= (-2)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 0")})((x <= 0))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } const z = 2; {console.log("---\nfor x in 0..z { ... } <=> x = 2")}; for (const x of $stdlib.std.Range.of(0, z, false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= 0)'`)})((x >= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x < 2)'`)})((x < 2))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= 0")})((x >= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x < 2")})((x < 2))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 0..=z { ... } <=> x = 2")}; for (const x of $stdlib.std.Range.of(0, z, true)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= 0)'`)})((x >= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 2)'`)})((x <= 2))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= 0")})((x >= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 2")})((x <= 2))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in z..0 { ... } <=> x = 2")}; for (const x of $stdlib.std.Range.of(z, 0, false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 2)'`)})((x <= 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x > 0)'`)})((x > 0))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 2")})((x <= 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x > 0")})((x > 0))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 0..(z*2) { ... } <=> x = 2")}; for (const x of $stdlib.std.Range.of(0, (z * 2), false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= 0)'`)})((x >= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x < 4)'`)})((x < 4))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= 0")})((x >= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x < 4")})((x < 4))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in 0..=(z*2) { ... } <=> x = 2")}; for (const x of $stdlib.std.Range.of(0, (z * 2), true)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x >= 0)'`)})((x >= 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 4)'`)})((x <= 4))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x >= 0")})((x >= 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 4")})((x <= 4))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } {console.log("---\nfor x in (z*2)..0 { ... } <=> x = 2")}; for (const x of $stdlib.std.Range.of((z * 2), 0, false)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x <= 4)'`)})((x <= 4))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x > 0)'`)})((x > 0))}; - {console.log(`${x}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: x <= 4")})((x <= 4))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x > 0")})((x > 0))}; + {console.log(String.raw({ raw: ["", ""] }, x))}; } this.node.root.newAbstract("@winglang/sdk.cloud.Function",this,"cloud.Function",new $Closure1(this,"$Closure1")); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.w_compile_tf-aws.md index 88a5230a271..f64b7a0654e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.w_compile_tf-aws.md @@ -64,7 +64,7 @@ class $Root extends $stdlib.std.Resource { } method2() { (this.method1()); - {console.log(`${this.f}`)}; + {console.log(String.raw({ raw: ["", ""] }, this.f))}; (this.method2()); } method1() { @@ -98,7 +98,7 @@ class $Root extends $stdlib.std.Resource { } const x = "hi"; if (true) { - {console.log(`${x}`)}; + {console.log(String.raw({ raw: ["", ""] }, x))}; const y = new R(this,"R"); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.w_compile_tf-aws.md index 671fc5a764c..e07be19e19d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.w_compile_tf-aws.md @@ -21,8 +21,8 @@ module.exports = function({ }) { ; const wingInflightFn = (await iFn("wing")); const dingInflightFn = (await iFn("ding")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await wingInflightFn())'`)})((await wingInflightFn()))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!(await dingInflightFn()))'`)})((!(await dingInflightFn())))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wingInflightFn()")})((await wingInflightFn()))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !dingInflightFn()")})((!(await dingInflightFn())))}; } } return $Closure1; @@ -203,8 +203,8 @@ class $Root extends $stdlib.std.Resource { ; const wingFn = (fn("wing")); const dingFn = (fn("ding")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(wingFn())'`)})((wingFn()))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!(dingFn()))'`)})((!(dingFn())))}; + {((cond) => {if (!cond) throw new Error("assertion failed: wingFn()")})((wingFn()))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !dingFn()")})((!(dingFn())))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:inflight functions can return other inflight functions",new $Closure1(this,"$Closure1")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/hello.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/hello.w_compile_tf-aws.md index 659bd6954a0..edb6c819ba4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/hello.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/hello.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ bucket }) { async $inflight_init() { } async handle(message) { - (await bucket.put("wing.txt",`Hello, ${message}`)); + (await bucket.put("wing.txt",String.raw({ raw: ["Hello, ", ""] }, message))); } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.w_compile_tf-aws.md index bac60655682..82f435d6503 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.w_compile_tf-aws.md @@ -44,8 +44,8 @@ class $Root extends $stdlib.std.Resource { super(scope, id); const d = (std.Duration.fromMinutes(5)); const n = ((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("12"); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(d.seconds === (5 * 60))'`)})((d.seconds === (5 * 60)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(n === 12)'`)})((n === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.seconds == 5 * 60")})((d.seconds === (5 * 60)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: n == 12")})((n === 12))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.w_compile_tf-aws.md index 325f65b4f55..da1e78af66b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ Preflight }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await Preflight.staticMethod(123)) === "foo-123")'`)})(((await Preflight.staticMethod(123)) === "foo-123"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Preflight.staticMethod(123) == \"foo-123\"")})(((await Preflight.staticMethod(123)) === "foo-123"))}; } } return $Closure1; @@ -32,7 +32,7 @@ module.exports = function({ OuterInflight }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await OuterInflight.staticMethod("hello")) === 5)'`)})(((await OuterInflight.staticMethod("hello")) === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: OuterInflight.staticMethod(\"hello\") == 5")})(((await OuterInflight.staticMethod("hello")) === 5))}; } } return $Closure2; @@ -53,7 +53,7 @@ module.exports = function({ }) { } async handle() { const InnerInflight = require("./inflight.InnerInflight.js")({}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await InnerInflight.staticMethod()) === "hello")'`)})(((await InnerInflight.staticMethod()) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: InnerInflight.staticMethod() == \"hello\"")})(((await InnerInflight.staticMethod()) === "hello"))}; } } return $Closure3; @@ -77,10 +77,10 @@ module.exports = function({ util_Util }) { const $IF_LET_VALUE = (await util_Util.tryEnv("WING_TARGET")); if ($IF_LET_VALUE != undefined) { const target = $IF_LET_VALUE; - {console.log(`WING_TARGET=${target}`)}; + {console.log(String.raw({ raw: ["WING_TARGET=", ""] }, target))}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false /* target not defined*/")})(false)}; } } } @@ -129,7 +129,7 @@ module.exports = function({ }) { async $inflight_init() { } static async staticMethod(a) { - return `foo-${a}`; + return String.raw({ raw: ["foo-", ""] }, a); } } return Preflight; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.w_compile_tf-aws.md index 743be69be70..d689c942cd4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.w_compile_tf-aws.md @@ -35,7 +35,7 @@ module.exports = function({ getBar }) { } async handle() { const bar = (await getBar()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await bar.foo.get()) === 42)'`)})(((await bar.foo.get()) === 42))}; + {((cond) => {if (!cond) throw new Error("assertion failed: bar.foo.get() == 42")})(((await bar.foo.get()) === 42))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.w_compile_tf-aws.md index 0694bfea0d4..be393d915a2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.w_compile_tf-aws.md @@ -13,7 +13,7 @@ module.exports = function({ myConst, Foo }) { } async handle() { const x = new Foo(); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await x.getValue()) === myConst)'`)})(((await x.getValue()) === myConst))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x.getValue() == myConst")})(((await x.getValue()) === myConst))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.w_compile_tf-aws.md index d51ba5c1b23..698f1266ed3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.w_compile_tf-aws.md @@ -14,7 +14,7 @@ module.exports = function({ }) { async handle() { const C = require("./inflight.C.js")({}); const c = new C(); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await c.foo()) === "c1")'`)})(((await c.foo()) === "c1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: c.foo() == \"c1\"")})(((await c.foo()) === "c1"))}; } } return $Closure1; @@ -54,12 +54,12 @@ module.exports = function({ a, fn, d, innerD, B }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await a.goo()) === "a2")'`)})(((await a.goo()) === "a2"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.goo() == \"a2\"")})(((await a.goo()) === "a2"))}; const b = new B(); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.foo()) === "b1")'`)})(((await b.foo()) === "b1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.foo() == \"b1\"")})(((await b.foo()) === "b1"))}; (await fn()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await d.callInner()) === "f1")'`)})(((await d.callInner()) === "f1"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await innerD()) === "f1")'`)})(((await innerD()) === "f1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d.callInner() == \"f1\"")})(((await d.callInner()) === "f1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: innerD() == \"f1\"")})(((await innerD()) === "f1"))}; } } return $Closure3; @@ -425,7 +425,7 @@ class $Root extends $stdlib.std.Resource { } } const pb = new E(this,"E"); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((pb.foo()) === "e1")'`)})(((pb.foo()) === "e1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: pb.foo() == \"e1\"")})(((pb.foo()) === "e1"))}; class F extends $stdlib.std.Resource { constructor(scope, id, ) { super(scope, id); @@ -578,7 +578,7 @@ class $Root extends $stdlib.std.Resource { } } const a = new A(this,"A"); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((a.foo()) === "a1")'`)})(((a.foo()) === "a1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: a.foo() == \"a1\"")})(((a.foo()) === "a1"))}; const fn = new $Closure1(this,"$Closure1"); const d = new D(this,"D"); const innerD = (d.getInner()); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.w_compile_tf-aws.md index df03758e895..2a8a86195a1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.w_compile_tf-aws.md @@ -15,9 +15,9 @@ module.exports = function({ }) { const y = [1]; let i = 10; const Inner = require("./inflight.Inner.js")({y, i}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await new Inner().dang()) === 11)'`)})(((await new Inner().dang()) === 11))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await y.at(1)) === 2)'`)})(((await y.at(1)) === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(i === 10)'`)})((i === 10))}; + {((cond) => {if (!cond) throw new Error("assertion failed: new Inner().dang() == 11")})(((await new Inner().dang()) === 11))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y.at(1) == 2")})(((await y.at(1)) === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: i == 10")})((i === 10))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.w_compile_tf-aws.md index 30fb426adc1..54f653fef04 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.w_compile_tf-aws.md @@ -59,7 +59,7 @@ module.exports = function({ }) { const Foo = require("./inflight.Foo.js")({x}); const foo = new Foo(); const y = (await foo.getX()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(y === 12)'`)})((y === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y == 12")})((y === 12))}; } } return $Closure3; @@ -90,7 +90,7 @@ module.exports = function({ }) { this.field = "value"; } async method() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.field === "value")'`)})((this.field === "value"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.field == \"value\"")})((this.field === "value"))}; } } return InflightClass; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.w_compile_tf-aws.md index 44f24ebae53..698975a86a0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.w_compile_tf-aws.md @@ -13,7 +13,7 @@ module.exports = function({ BinaryOperation }) { } async handle() { const op = new BinaryOperation(10,20); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await op.add()) === 30)'`)})(((await op.add()) === 30))}; + {((cond) => {if (!cond) throw new Error("assertion failed: op.add() == 30")})(((await op.add()) === 30))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.w_compile_tf-aws.md index 4698868681b..16bfb58377b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.w_compile_tf-aws.md @@ -14,9 +14,9 @@ module.exports = function({ NotGoo }) { async handle() { const YesGoo = require("./inflight.YesGoo.js")({}); const y = new YesGoo(); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await y.handle()) === 456)'`)})(((await y.handle()) === 456))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y.handle() == 456")})(((await y.handle()) === 456))}; const x = new NotGoo(); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await x.handle()) === 123)'`)})(((await x.handle()) === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x.handle() == 123")})(((await x.handle()) === 123))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.w_compile_tf-aws.md index c4ced9b0bf3..b1ad855393a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.w_compile_tf-aws.md @@ -53,7 +53,7 @@ module.exports = function({ func1, globalBucket }) { } async handle() { (await func1.invoke("hi1")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await globalBucket.get("file1")) === "hi1")'`)})(((await globalBucket.get("file1")) === "hi1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalBucket.get(\"file1\") == \"hi1\"")})(((await globalBucket.get("file1")) === "hi1"))}; } } return $Closure3; @@ -95,7 +95,7 @@ module.exports = function({ x }) { } async handle() { const val = (await x.foo()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(val === "hello")'`)})((val === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: val == \"hello\"")})((val === "hello"))}; } } return $Closure5; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json.w_compile_tf-aws.md index 7169dce44a3..66c72bdebf7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json.w_compile_tf-aws.md @@ -96,7 +96,7 @@ class $Root extends $stdlib.std.Resource { const jsonMutObj = {"hello":123,"world":[1, "cat", 3],"boom boom":{"hello":1233}}; const message = "Coolness"; ((obj, args) => { obj[args[0]] = args[1]; })(jsonMutObj, ["hello",message]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((jsonMutObj)["hello"] === message)'`)})(((jsonMutObj)["hello"] === message))}; + {((cond) => {if (!cond) throw new Error("assertion failed: jsonMutObj.get(\"hello\") == message")})(((jsonMutObj)["hello"] === message))}; const someNumber = 999; const jj = someNumber; const jj1 = Object.freeze({"foo":someNumber}); @@ -106,24 +106,24 @@ class $Root extends $stdlib.std.Resource { } ; const jj3 = (getStr()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(jj3 === "hello")'`)})((jj3 === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: jj3 == Json \"hello\"")})((jj3 === "hello"))}; const f = new Foo(this,"Foo"); const jj4 = f.SumStr; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(jj4 === "wow!")'`)})((jj4 === "wow!"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: jj4 == Json \"wow!\"")})((jj4 === "wow!"))}; const someJson = {"x":someNumber}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((someJson)["x"] === someNumber)'`)})(((someJson)["x"] === someNumber))}; + {((cond) => {if (!cond) throw new Error("assertion failed: someJson.get(\"x\") == someNumber")})(((someJson)["x"] === someNumber))}; ((obj, args) => { obj[args[0]] = args[1]; })(someJson, ["x",111]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((someJson)["x"] === 111)'`)})(((someJson)["x"] === 111))}; + {((cond) => {if (!cond) throw new Error("assertion failed: someJson.get(\"x\") == 111")})(((someJson)["x"] === 111))}; const x = Object.freeze({"cool":"beans"}); const nestedJson = {"a":"hello","b":{"c":"world","d":{"foo":"foo","bar":123}}}; ((obj, args) => { obj[args[0]] = args[1]; })(((nestedJson)["b"])["d"], ["foo","tastic"]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((nestedJson)["b"])["d"])["foo"] === "tastic")'`)})(((((nestedJson)["b"])["d"])["foo"] === "tastic"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((nestedJson)["b"])["d"])["bar"] === 123)'`)})(((((nestedJson)["b"])["d"])["bar"] === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: nestedJson.get(\"b\").get(\"d\").get(\"foo\") == \"tastic\"")})(((((nestedJson)["b"])["d"])["foo"] === "tastic"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: nestedJson.get(\"b\").get(\"d\").get(\"bar\") == 123")})(((((nestedJson)["b"])["d"])["bar"] === 123))}; const b = "buckle"; const arr = [1, 2, b, "my", "shoe", 3, 4, ["shut", "the", "door"]]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr)[0] === 1)'`)})(((arr)[0] === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr)[2] === b)'`)})(((arr)[2] === b))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((arr)[7])[0] === "shut")'`)})((((arr)[7])[0] === "shut"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr.getAt(0) == 1")})(((arr)[0] === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr.getAt(2) == b")})(((arr)[2] === b))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr.getAt(7).getAt(0) == \"shut\"")})((((arr)[7])[0] === "shut"))}; Object.freeze({"a":[1, 2, "world"],"b":[1, 2, "world"]}); const emptyJson = Object.freeze({}); const emptyJsonArr = []; @@ -136,9 +136,9 @@ class $Root extends $stdlib.std.Resource { const theTowerOfJson = {"a":{},"b":{"c":{},"d":[[[{}]]]},"e":{"f":{"g":{},"h":[{}, []]}}}; ((obj, args) => { obj[args[0]] = args[1]; })(((((theTowerOfJson)["e"])["f"])["h"])[0], ["a",1]); const thatSuperNestedValue = (((((theTowerOfJson)["e"])["f"])["h"])[0])["a"]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(thatSuperNestedValue) === 1)'`)})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(thatSuperNestedValue) === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: num.fromJson(thatSuperNestedValue) == 1")})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })(thatSuperNestedValue) === 1))}; const unestedJsonArr = [1, 2, 3]; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((unestedJsonArr)[0] === 1)'`)})(((unestedJsonArr)[0] === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: unestedJsonArr.getAt(0) == 1")})(((unestedJsonArr)[0] === 1))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.w_compile_tf-aws.md index 51268064971..87ba7f04d67 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.w_compile_tf-aws.md @@ -13,7 +13,7 @@ module.exports = function({ b, fileName }) { } async handle(msg) { const x = (await b.getJson(fileName)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((((x)["persons"])[0])["fears"])[1] === "failure")'`)})((((((x)["persons"])[0])["fears"])[1] === "failure"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x.get(\"persons\").getAt(0).get(\"fears\").getAt(1) == \"failure\"")})((((((x)["persons"])[0])["fears"])[1] === "failure"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_static.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_static.w_compile_tf-aws.md index 93ddcf5ec98..b497644463f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_static.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_static.w_compile_tf-aws.md @@ -13,7 +13,7 @@ module.exports = function({ jj, std_Json }) { } async handle() { const ss = ((args) => { return JSON.stringify(args[0], null, args[1]) })([jj]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(ss === "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}")'`)})((ss === "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: ss == \"{\\\"a\\\":123,\\\"b\\\":{\\\"c\\\":456,\\\"d\\\":789}}\"")})((ss === "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}"))}; } } return $Closure1; @@ -34,8 +34,8 @@ module.exports = function({ std_Json }) { } async handle() { const hasCheck = Object.freeze({"a":"hello","b":"wing"}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return args[0].hasOwnProperty(args[1]); })([hasCheck,"a"]) === true)'`)})((((args) => { return args[0].hasOwnProperty(args[1]); })([hasCheck,"a"]) === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { return args[0].hasOwnProperty(args[1]); })([hasCheck,"c"]) === false)'`)})((((args) => { return args[0].hasOwnProperty(args[1]); })([hasCheck,"c"]) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.has(hasCheck, \"a\") == true")})((((args) => { return args[0].hasOwnProperty(args[1]); })([hasCheck,"a"]) === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.has(hasCheck, \"c\") == false")})((((args) => { return args[0].hasOwnProperty(args[1]); })([hasCheck,"c"]) === false))}; } } return $Closure2; @@ -315,34 +315,34 @@ class $Root extends $stdlib.std.Resource { } const x = Object.freeze({"a":123,"b":{"c":456,"d":789}}); const k = (Object.keys(x)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(k.length === 2)'`)})((k.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: k.length == 2")})((k.length === 2))}; const v = (Object.values(x)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((v.at(0)) === 123)'`)})(((v.at(0)) === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: v.at(0) == 123")})(((v.at(0)) === 123))}; const m = (JSON.parse(JSON.stringify(x))); ((obj, args) => { obj[args[0]] = args[1]; })(m, ["a",321]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m)["a"] === 321)'`)})(((m)["a"] === 321))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m.get(\"a\") == 321")})(((m)["a"] === 321))}; const n = Object.freeze(JSON.parse(JSON.stringify(m))); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(m !== n)'`)})((m !== n))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m != n")})((m !== n))}; let k2 = (Object.keys(m)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(k2.length === 2)'`)})((k2.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: k2.length == 2")})((k2.length === 2))}; ((args) => { delete (args[0])[args[1]]; })([m,"b"]); k2 = (Object.keys(m)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(k2.length === 1)'`)})((k2.length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: k2.length == 1")})((k2.length === 1))}; const s = "{\"a\": 123, \"b\": {\"c\": 456, \"d\": 789}}"; const j = (JSON.parse(s)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Object.keys(j)).length === 2)'`)})(((Object.keys(j)).length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.keys(j).length == 2")})(((Object.keys(j)).length === 2))}; const invalidJson = "invalid"; const tryParsed = (((args) => { try { return JSON.parse(args); } catch (err) { return undefined; } })(invalidJson) ?? Object.freeze({"key":"value"})); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((tryParsed)["key"] === "value")'`)})(((tryParsed)["key"] === "value"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: tryParsed.get(\"key\") == \"value\"")})(((tryParsed)["key"] === "value"))}; const jj = Object.freeze({"a":123,"b":{"c":456,"d":789}}); const ss = ((args) => { return JSON.stringify(args[0], null, args[1]) })([jj]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(ss === "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}")'`)})((ss === "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: ss == \"{\\\"a\\\":123,\\\"b\\\":{\\\"c\\\":456,\\\"d\\\":789}}\"")})((ss === "{\"a\":123,\"b\":{\"c\":456,\"d\":789}}"))}; const ss2 = ((args) => { return JSON.stringify(args[0], null, args[1]) })([jj,2]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(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}"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: 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 = Object.freeze({"a":123,"b":"hello","c":true}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((jsonOfMany)["b"]) === "hello")'`)})((((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((jsonOfMany)["b"]) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })((jsonOfMany)["a"]) === 123)'`)})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })((jsonOfMany)["a"]) === 123))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(std.Boolean.fromJson((jsonOfMany)["c"]))'`)})((std.Boolean.fromJson((jsonOfMany)["c"])))}; + {((cond) => {if (!cond) throw new Error("assertion failed: str.fromJson(jsonOfMany.get(\"b\")) == \"hello\"")})((((args) => { if (typeof args !== "string") {throw new Error("unable to parse " + typeof args + " " + args + " as a string")}; return JSON.parse(JSON.stringify(args)) })((jsonOfMany)["b"]) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: num.fromJson(jsonOfMany.get(\"a\")) == 123")})((((args) => { if (typeof args !== "number") {throw new Error("unable to parse " + typeof args + " " + args + " as a number")}; return JSON.parse(JSON.stringify(args)) })((jsonOfMany)["a"]) === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: bool.fromJson(jsonOfMany.get(\"c\"))")})((std.Boolean.fromJson((jsonOfMany)["c"])))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:Access Json static inflight",new $Closure1(this,"$Closure1")); this.node.root.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.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.w_compile_tf-aws.md index 36355e67142..4a134c7f47c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.w_compile_tf-aws.md @@ -43,10 +43,10 @@ class $Root extends $stdlib.std.Resource { constructor(scope, id) { super(scope, id); const obj = Object.freeze({"strValue":"test","numValue":1}); - const notStringifyStrValue = `string: ${((e) => typeof e === 'string' ? e : JSON.stringify(e, null, 2))((obj)["strValue"])}`; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(notStringifyStrValue === "string: test")'`)})((notStringifyStrValue === "string: test"))}; - const stringifyNumValue = `number: ${((e) => typeof e === 'string' ? e : JSON.stringify(e, null, 2))((obj)["numValue"])}`; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(stringifyNumValue === "number: 1")'`)})((stringifyNumValue === "number: 1"))}; + const notStringifyStrValue = String.raw({ raw: ["string: ", ""] }, ((e) => typeof e === 'string' ? e : JSON.stringify(e, null, 2))((obj)["strValue"])); + {((cond) => {if (!cond) throw new Error("assertion failed: notStringifyStrValue == \"string: test\"")})((notStringifyStrValue === "string: test"))}; + const stringifyNumValue = String.raw({ raw: ["number: ", ""] }, ((e) => typeof e === 'string' ? e : JSON.stringify(e, null, 2))((obj)["numValue"])); + {((cond) => {if (!cond) throw new Error("assertion failed: stringifyNumValue == \"number: 1\"")})((stringifyNumValue === "number: 1"))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.w_compile_tf-aws.md index bfa999faeb0..99e65aeea1a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.w_compile_tf-aws.md @@ -178,35 +178,35 @@ class $Root extends $stdlib.std.Resource { (arr1.push("a")); (arr2.push(4)); (arr3.push(bucket3)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr2.pop()) === 4)'`)})(((arr2.pop()) === 4))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr1.length === 4)'`)})((arr1.length === 4))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((arr4.at(0)) === "a")'`)})(((arr4.at(0)) === "a"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr2.pop() == 4")})(((arr2.pop()) === 4))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr1.length == 4")})((arr1.length === 4))}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr4.at(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]); (s1.add(5)); (s2.add("bye")); (s3.add(bucket3)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s2.has("bye"))'`)})((s2.has("bye")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s2.has("hello"))'`)})((s2.has("hello")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s3.has(bucket2))'`)})((s3.has(bucket2)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s2.has(\"bye\")")})((s2.has("bye")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s2.has(\"hello\")")})((s2.has("hello")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s3.has(bucket2)")})((s3.has(bucket2)))}; const m1 = {"hello":"world"}; const m2 = {"hello":123}; const m3 = {"b1":bucket1,"b2":bucket2}; const m4 = m1; const m5 = {"goodbye":"world"}; const m6 = {"a":m1,"b":m5}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("hello" in (m1))'`)})(("hello" in (m1)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m2).length === 1)'`)})((Object.keys(m2).length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m3)["b1"] === bucket1)'`)})(((m3)["b1"] === bucket1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m4).length === 1)'`)})((Object.keys(m4).length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((m6)["a"])["hello"] === "world")'`)})((((m6)["a"])["hello"] === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m1.has(\"hello\")")})(("hello" in (m1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m2.size() == 1")})((Object.keys(m2).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m3.get(\"b1\") == bucket1")})(((m3)["b1"] === bucket1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m4.size() == 1")})((Object.keys(m4).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m6.get(\"a\").get(\"hello\") == \"world\"")})((((m6)["a"])["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); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(m2).length === 0)'`)})((Object.keys(m2).length === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((m1)["hello"] === "goodbye")'`)})(((m1)["hello"] === "goodbye"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((m6)["a"])["foo"] === "bar")'`)})((((m6)["a"])["foo"] === "bar"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m2.size() == 0")})((Object.keys(m2).length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m1.get(\"hello\") == \"goodbye\"")})(((m1)["hello"] === "goodbye"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: m6.get(\"a\").get(\"foo\") == \"bar\"")})((((m6)["a"])["foo"] === "bar"))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/nil.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/nil.w_compile_tf-aws.md index 94e1e0b177f..f1690b2f88c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/nil.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/nil.w_compile_tf-aws.md @@ -12,8 +12,8 @@ module.exports = function({ foo }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((await foo.returnNil(true))) != null) === true)'`)})(((((await foo.returnNil(true))) != null) === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((await foo.returnNil(false))) != null) === false)'`)})(((((await foo.returnNil(false))) != null) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.returnNil(true)? == true")})(((((await foo.returnNil(true))) != null) === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.returnNil(false)? == false")})(((((await foo.returnNil(false))) != null) === false))}; } } return $Closure1; @@ -33,13 +33,13 @@ module.exports = function({ foo }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((await foo.getOptionalValue())) != null) === false)'`)})(((((await foo.getOptionalValue())) != null) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.getOptionalValue()? == false")})(((((await foo.getOptionalValue())) != null) === false))}; (await foo.setOptionalValue("hello")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((await foo.getOptionalValue())) != null) === true)'`)})(((((await foo.getOptionalValue())) != null) === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await foo.getOptionalValue()) !== undefined)'`)})(((await foo.getOptionalValue()) !== undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.getOptionalValue()? == true")})(((((await foo.getOptionalValue())) != null) === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.getOptionalValue() != nil")})(((await foo.getOptionalValue()) !== undefined))}; (await foo.setOptionalValue(undefined)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((await foo.getOptionalValue())) != null) === false)'`)})(((((await foo.getOptionalValue())) != null) === false))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await foo.getOptionalValue()) === undefined)'`)})(((await foo.getOptionalValue()) === undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.getOptionalValue()? == false")})(((((await foo.getOptionalValue())) != null) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.getOptionalValue() == nil")})(((await foo.getOptionalValue()) === undefined))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/optionals.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/optionals.w_compile_tf-aws.md index 88c3130f39d..6bd83f41cb8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/optionals.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/optionals.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ payloadWithoutOptions, payloadWithBucket }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((payloadWithoutOptions.b) != null) === false)'`)})((((payloadWithoutOptions.b) != null) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: payloadWithoutOptions.b? == false")})((((payloadWithoutOptions.b) != null) === false))}; if (((payloadWithBucket.c) != null)) { (await payloadWithBucket.c.put("x.txt","something")); } @@ -441,14 +441,14 @@ class $Root extends $stdlib.std.Resource { } } const x = 4; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((x) != null) === true)'`)})((((x) != null) === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((!((x) != null)) === false)'`)})(((!((x) != null)) === false))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((x ?? 5) === 4)'`)})(((x ?? 5) === 4))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x? == true")})((((x) != null) === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !x? == false")})(((!((x) != null)) === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x ?? 5 == 4")})(((x ?? 5) === 4))}; const y = (x ?? 5); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(y === 4)'`)})((y === 4))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y == 4")})((y === 4))}; const optionalSup = new Super(this,"Super"); const s = (optionalSup ?? new Sub(this,"Sub")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s.name === "Super")'`)})((s.name === "Super"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s.name == \"Super\"")})((s.name === "Super"))}; let name = { "first": "John", "last": "Doe",} @@ -457,7 +457,7 @@ class $Root extends $stdlib.std.Resource { const $IF_LET_VALUE = name; if ($IF_LET_VALUE != undefined) { const n = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(n.first === "John")'`)})((n.first === "John"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: n.first == \"John\"")})((n.first === "John"))}; } } name = undefined; @@ -465,10 +465,10 @@ class $Root extends $stdlib.std.Resource { const $IF_LET_VALUE = name; if ($IF_LET_VALUE != undefined) { const n = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'true'`)})(true)}; + {((cond) => {if (!cond) throw new Error("assertion failed: true")})(true)}; } } const tryParseName = (fullName) => { @@ -486,15 +486,15 @@ class $Root extends $stdlib.std.Resource { const $IF_LET_VALUE = (tryParseName("Good Name")); if ($IF_LET_VALUE != undefined) { const parsedName = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(parsedName.first === "Good")'`)})((parsedName.first === "Good"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: parsedName.first == \"Good\"")})((parsedName.first === "Good"))}; { const $IF_LET_VALUE = parsedName.last; if ($IF_LET_VALUE != undefined) { const lastName = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(lastName === "Name")'`)})((lastName === "Name"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: lastName == \"Name\"")})((lastName === "Name"))}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } } @@ -503,12 +503,12 @@ class $Root extends $stdlib.std.Resource { const $IF_LET_VALUE = (tryParseName("BadName")); if ($IF_LET_VALUE != undefined) { const parsedName = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(parsedName.first === "BadName")'`)})((parsedName.first === "BadName"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: parsedName.first == \"BadName\"")})((parsedName.first === "BadName"))}; { const $IF_LET_VALUE = parsedName.last; if ($IF_LET_VALUE != undefined) { const lastName = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } } @@ -518,10 +518,10 @@ class $Root extends $stdlib.std.Resource { const $IF_LET_VALUE = falsy; if ($IF_LET_VALUE != undefined) { const f = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(f === false)'`)})((f === false))}; + {((cond) => {if (!cond) throw new Error("assertion failed: f == false")})((f === false))}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } const shadow = "root"; @@ -529,16 +529,16 @@ class $Root extends $stdlib.std.Resource { const $IF_LET_VALUE = shadow; if ($IF_LET_VALUE != undefined) { const shadow = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(shadow === "root")'`)})((shadow === "root"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: shadow == \"root\"")})((shadow === "root"))}; const shadow1 = "nested"; { const $IF_LET_VALUE = shadow1; if ($IF_LET_VALUE != undefined) { const shadow1 = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(shadow1 === "nested")'`)})((shadow1 === "nested"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: shadow1 == \"nested\"")})((shadow1 === "nested"))}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } } @@ -556,18 +556,18 @@ class $Root extends $stdlib.std.Resource { } } ; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((fun("hello")) === "hello")'`)})(((fun("hello")) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((fun(undefined)) === "default")'`)})(((fun(undefined)) === "default"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fun(\"hello\") == \"hello\"")})(((fun("hello")) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fun(nil) == \"default\"")})(((fun(undefined)) === "default"))}; const tree = new Node(this,"eight",8,new Node(this,"three",3,new Node(this,"one",1,undefined,undefined),new Node(this,"six",6,undefined,undefined)),new Node(this,"ten",10,undefined,new Node(this,"fourteen",14,new Node(this,"thirteen",13,undefined,undefined),undefined))); const thirteen = tree.right.right.left.value; const notThere = tree.right.right.right; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(thirteen === 13)'`)})((thirteen === 13))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(notThere === undefined)'`)})((notThere === undefined))}; + {((cond) => {if (!cond) throw new Error("assertion failed: thirteen == 13")})((thirteen === 13))}; + {((cond) => {if (!cond) throw new Error("assertion failed: notThere == nil")})((notThere === undefined))}; { const $IF_LET_VALUE = tree.left.left; if ($IF_LET_VALUE != undefined) { const o = $IF_LET_VALUE; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(o.value === 1)'`)})((o.value === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: o.value == 1")})((o.value === 1))}; } } const payloadWithoutOptions = { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.w_compile_tf-aws.md index 158b78a4c65..52831faed87 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.w_compile_tf-aws.md @@ -47,12 +47,12 @@ class $Root extends $stdlib.std.Resource { const f = (d) => { } ; - const stringy = `${dur.minutes}:${dur.seconds}`; + const stringy = String.raw({ raw: ["", ":", ""] }, dur.minutes, dur.seconds); {console.log(stringy)}; if ((stringy.includes("60") && (((stringy.split(":")).at(0)) === "60"))) { - {console.log(`${stringy.length}!`)}; + {console.log(String.raw({ raw: ["", "!"] }, stringy.length))}; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("123") === 123)'`)})((((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("123") === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: num.fromStr(\"123\") == 123")})((((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return parseInt(args) })("123") === 123))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.w_compile_tf-aws.md index f243b162117..843ae77e038 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.w_compile_tf-aws.md @@ -100,20 +100,20 @@ class $Root extends $stdlib.std.Resource { } } let x = 5; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === 5)'`)})((x === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == 5")})((x === 5))}; x = (x + 1); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === 6)'`)})((x === 6))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == 6")})((x === 6))}; const r = new R(this,"R"); (r.inc()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(r.f === 2)'`)})((r.f === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: r.f == 2")})((r.f === 2))}; const f = (arg) => { arg = 0; return arg; } ; const y = 1; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((f(y)) === 0)'`)})(((f(y)) === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(y === 1)'`)})((y === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: f(y) == 0")})(((f(y)) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y == 1")})((y === 1))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/redis.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/redis.w_compile_tf-aws.md index f11917abe95..a78a976cb9d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/redis.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/redis.w_compile_tf-aws.md @@ -15,10 +15,10 @@ module.exports = function({ r, r2 }) { const connection = (await r.rawClient()); (await connection.set("wing","does redis")); const value = (await connection.get("wing")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(value === "does redis")'`)})((value === "does redis"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: value == \"does redis\"")})((value === "does redis"))}; (await r2.set("wing","does redis again")); const value2 = (await r2.get("wing")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(value2 === "does redis again")'`)})((value2 === "does redis again"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: value2 == \"does redis again\"")})((value2 === "does redis again"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource.w_compile_tf-aws.md index e8e5c77422e..d0453c9805c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource.w_compile_tf-aws.md @@ -13,9 +13,9 @@ module.exports = function({ res, bucket }) { } async handle() { const s = (await res.myMethod()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "counter is: 101")'`)})((s === "counter is: 101"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await bucket.list()).length === 1)'`)})(((await bucket.list()).length === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(res.foo.inflightField === 123)'`)})((res.foo.inflightField === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"counter is: 101\"")})((s === "counter is: 101"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: bucket.list().length == 1")})(((await bucket.list()).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: res.foo.inflightField == 123")})((res.foo.inflightField === 123))}; (await res.testTypeAccess()); } } @@ -123,14 +123,14 @@ module.exports = function({ Foo, MyEnum }) { async myMethod() { (await this.foo.fooInc()); const s = (await Foo.fooStatic()); - (await this.b.put("foo",`counter is: ${(await this.foo.fooGet())}`)); + (await this.b.put("foo",String.raw({ raw: ["counter is: ", ""] }, (await this.foo.fooGet())))); return (await this.b.get("foo")); } async testTypeAccess() { if (true) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await Bar.barStatic()) === "bar static")'`)})(((await Bar.barStatic()) === "bar static"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await Foo.fooStatic()) === "foo static")'`)})(((await Foo.fooStatic()) === "foo static"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.e === MyEnum.B)'`)})((this.e === MyEnum.B))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Bar.barStatic() == \"bar static\"")})(((await Bar.barStatic()) === "bar static"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Foo.fooStatic() == \"foo static\"")})(((await Foo.fooStatic()) === "foo static"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.e == MyEnum.B")})((this.e === MyEnum.B))}; } } } @@ -1303,13 +1303,13 @@ class $Root extends $stdlib.std.Resource { constructor(scope, id, ) { super(scope, id); const d1 = new Dummy(this,"Dummy"); - {((cond) => {if (!cond) throw new Error(`assertion failed: 'd1.node.path.endsWith("/ScopeAndIdTestClass/Dummy")'`)})(d1.node.path.endsWith("/ScopeAndIdTestClass/Dummy"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d1.node.path.endsWith(\"/ScopeAndIdTestClass/Dummy\")")})(d1.node.path.endsWith("/ScopeAndIdTestClass/Dummy"))}; const d2 = new Dummy(d1,"Dummy"); - {((cond) => {if (!cond) throw new Error(`assertion failed: 'd2.node.path.endsWith("/ScopeAndIdTestClass/Dummy/Dummy")'`)})(d2.node.path.endsWith("/ScopeAndIdTestClass/Dummy/Dummy"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: d2.node.path.endsWith(\"/ScopeAndIdTestClass/Dummy/Dummy\")")})(d2.node.path.endsWith("/ScopeAndIdTestClass/Dummy/Dummy"))}; for (const i of $stdlib.std.Range.of(0, 3, false)) { - const x = new Dummy(this,`tc${i}`); - const expected_path = `/ScopeAndIdTestClass/tc${i}`; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'x.node.path.endsWith(expected_path)'`)})(x.node.path.endsWith(expected_path))}; + const x = new Dummy(this,String.raw({ raw: ["tc", ""] }, i)); + const expected_path = String.raw({ raw: ["/ScopeAndIdTestClass/tc", ""] }, i); + {((cond) => {if (!cond) throw new Error("assertion failed: x.node.path.endsWith(expected_path)")})(x.node.path.endsWith(expected_path))}; } } static _toInflightType(context) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.w_compile_tf-aws.md index 70dd88a6282..a03dcf6dd1b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ fn }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await fn.invoke("test")) === "hello world!")'`)})(((await fn.invoke("test")) === "hello world!"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: fn.invoke(\"test\") == \"hello world!\"")})(((await fn.invoke("test")) === "hello world!"))}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.w_compile_tf-aws.md index d8f6fdb1581..358bc5d65c5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.w_compile_tf-aws.md @@ -91,54 +91,54 @@ module.exports = function({ }) { } async testNoCapture() { const arr = Object.freeze([1, 2, 3]); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(arr.length === 3)'`)})((arr.length === 3))}; - {console.log(`array.len=${arr.length}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: arr.length == 3")})((arr.length === 3))}; + {console.log(String.raw({ raw: ["array.len=", ""] }, arr.length))}; } async testCaptureCollectionsOfData() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.arrayOfStr.length === 2)'`)})((this.arrayOfStr.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.arrayOfStr.at(0)) === "s1")'`)})(((await this.arrayOfStr.at(0)) === "s1"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.arrayOfStr.at(1)) === "s2")'`)})(((await this.arrayOfStr.at(1)) === "s2"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((this.mapOfNum)["k1"] === 11)'`)})(((this.mapOfNum)["k1"] === 11))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((this.mapOfNum)["k2"] === 22)'`)})(((this.mapOfNum)["k2"] === 22))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await this.setOfStr.has("s1"))'`)})((await this.setOfStr.has("s1")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await this.setOfStr.has("s2"))'`)})((await this.setOfStr.has("s2")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!(await this.setOfStr.has("s3")))'`)})((!(await this.setOfStr.has("s3"))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.arrayOfStr.length == 2")})((this.arrayOfStr.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.arrayOfStr.at(0) == \"s1\"")})(((await this.arrayOfStr.at(0)) === "s1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.arrayOfStr.at(1) == \"s2\"")})(((await this.arrayOfStr.at(1)) === "s2"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.mapOfNum.get(\"k1\") == 11")})(((this.mapOfNum)["k1"] === 11))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.mapOfNum.get(\"k2\") == 22")})(((this.mapOfNum)["k2"] === 22))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.setOfStr.has(\"s1\")")})((await this.setOfStr.has("s1")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.setOfStr.has(\"s2\")")})((await this.setOfStr.has("s2")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !this.setOfStr.has(\"s3\")")})((!(await this.setOfStr.has("s3"))))}; } async testCapturePrimitives() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.myStr === "myString")'`)})((this.myStr === "myString"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.myNum === 42)'`)})((this.myNum === 42))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.myBool === true)'`)})((this.myBool === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.myStr == \"myString\"")})((this.myStr === "myString"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.myNum == 42")})((this.myNum === 42))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.myBool == true")})((this.myBool === true))}; } async testCaptureOptional() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((this.myOptStr ?? "") === "myOptString")'`)})(((this.myOptStr ?? "") === "myOptString"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.myOptStr ?? \"\" == \"myOptString\"")})(((this.myOptStr ?? "") === "myOptString"))}; } async testCaptureResource() { (await this.myResource.put("f1.txt","f1")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.myResource.get("f1.txt")) === "f1")'`)})(((await this.myResource.get("f1.txt")) === "f1"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.myResource.list()).length === 1)'`)})(((await this.myResource.list()).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.myResource.get(\"f1.txt\") == \"f1\"")})(((await this.myResource.get("f1.txt")) === "f1"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.myResource.list().length == 1")})(((await this.myResource.list()).length === 1))}; } async testNestedInflightField() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.another.myField === "hello!")'`)})((this.another.myField === "hello!"))}; - {console.log(`field=${this.another.myField}`)}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.another.myField == \"hello!\"")})((this.another.myField === "hello!"))}; + {console.log(String.raw({ raw: ["field=", ""] }, this.another.myField))}; } async testNestedResource() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.another.first.myResource.list()).length === 0)'`)})(((await this.another.first.myResource.list()).length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.another.first.myResource.list().length == 0")})(((await this.another.first.myResource.list()).length === 0))}; (await this.another.first.myResource.put("hello",this.myStr)); - {console.log(`this.another.first.myResource:${(await this.another.first.myResource.get("hello"))}`)}; + {console.log(String.raw({ raw: ["this.another.first.myResource:", ""] }, (await this.another.first.myResource.get("hello"))))}; } async testExpressionRecursive() { (await this.myQueue.push(this.myStr)); } async testExternal() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.extBucket.list()).length === 0)'`)})(((await this.extBucket.list()).length === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.extNum === 12)'`)})((this.extNum === 12))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.extBucket.list().length == 0")})(((await this.extBucket.list()).length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.extNum == 12")})((this.extNum === 12))}; } async testUserDefinedResource() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.another.meaningOfLife()) === 42)'`)})(((await this.another.meaningOfLife()) === 42))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await this.another.anotherFunc()) === "42")'`)})(((await this.another.anotherFunc()) === "42"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.another.meaningOfLife() == 42")})(((await this.another.meaningOfLife()) === 42))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.another.anotherFunc() == \"42\"")})(((await this.another.anotherFunc()) === "42"))}; } async testInflightField() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(this.inflightField === 123)'`)})((this.inflightField === 123))}; + {((cond) => {if (!cond) throw new Error("assertion failed: this.inflightField == 123")})((this.inflightField === 123))}; } } return MyResource; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.w_compile_tf-aws.md index 9c787722191..5559e50b3e9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.w_compile_tf-aws.md @@ -32,7 +32,7 @@ module.exports = function({ Another }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await Another.myStaticMethod()) === 0)'`)})(((await Another.myStaticMethod()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Another.myStaticMethod() == 0")})(((await Another.myStaticMethod()) === 0))}; } } return $Closure2; @@ -49,7 +49,7 @@ module.exports = function({ globalCounter }) { this.myField = myField; } async $inflight_init() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await globalCounter.peek()) === 0)'`)})(((await globalCounter.peek()) === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalCounter.peek() == 0")})(((await globalCounter.peek()) === 0))}; } async myMethod() { (await globalCounter.inc()); @@ -92,16 +92,16 @@ module.exports = function({ globalBucket, globalStr, globalBool, globalNum, glob async myPut() { (await this.localTopic.publish("hello")); (await globalBucket.put("key","value")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(globalStr === "hello")'`)})((globalStr === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(globalBool === true)'`)})((globalBool === true))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(globalNum === 42)'`)})((globalNum === 42))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await globalArrayOfStr.at(0)) === "hello")'`)})(((await globalArrayOfStr.at(0)) === "hello"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((globalMapOfNum)["a"] === (-5))'`)})(((globalMapOfNum)["a"] === (-5)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(await globalSetOfStr.has("a"))'`)})((await globalSetOfStr.has("a")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(globalAnother.myField === "hello!")'`)})((globalAnother.myField === "hello!"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalStr == \"hello\"")})((globalStr === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalBool == true")})((globalBool === true))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalNum == 42")})((globalNum === 42))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalArrayOfStr.at(0) == \"hello\"")})(((await globalArrayOfStr.at(0)) === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalMapOfNum.get(\"a\") == -5")})(((globalMapOfNum)["a"] === (-5)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalSetOfStr.has(\"a\")")})((await globalSetOfStr.has("a")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalAnother.myField == \"hello!\"")})((globalAnother.myField === "hello!"))}; (await globalAnother.first.myResource.put("key","value")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await globalAnother.myMethod()) > 0)'`)})(((await globalAnother.myMethod()) > 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await Another.myStaticMethod()) > 0)'`)})(((await Another.myStaticMethod()) > 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: globalAnother.myMethod() > 0")})(((await globalAnother.myMethod()) > 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Another.myStaticMethod() > 0")})(((await Another.myStaticMethod()) > 0))}; } } return MyResource; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.w_compile_tf-aws.md index 6a30ba72f32..37537319a85 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.w_compile_tf-aws.md @@ -41,10 +41,10 @@ module.exports = function({ fn }) { } async handle() { const result = (await fn()); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(result.length === 3)'`)})((result.length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await result.at(0)) === "hola!")'`)})(((await result.at(0)) === "hola!"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await result.at(1)) === "world")'`)})(((await result.at(1)) === "world"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await result.at(2)) === "bang")'`)})(((await result.at(2)) === "bang"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: result.length == 3")})((result.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: result.at(0) == \"hola!\"")})(((await result.at(0)) === "hola!"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: result.at(1) == \"world\"")})(((await result.at(1)) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: result.at(2) == \"bang\"")})(((await result.at(2)) === "bang"))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.w_compile_tf-aws.md index 17bdc14d1a1..373e57d54c8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.w_compile_tf-aws.md @@ -16,20 +16,20 @@ module.exports = function({ }) { const x = 2; if ((true && ((x + 2) === 4))) { if ((true && ((x + 3) === 4))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } else if ((true && ((x + 3) === 6))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } else if ((false || ((x + 3) === 5))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'true'`)})(true)}; + {((cond) => {if (!cond) throw new Error("assertion failed: true")})(true)}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } } @@ -208,23 +208,23 @@ class $Root extends $stdlib.std.Resource { const f = false; if ((true && ((x + 2) === 4))) { if ((true && ((x + 3) === 4))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } else if ((true && ((x + 3) === 6))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } else if ((false || ((x + 3) === 5))) { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'true'`)})(true)}; + {((cond) => {if (!cond) throw new Error("assertion failed: true")})(true)}; } else if ((!f)) { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!(!(!f)))'`)})((!(!(!f))))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !!!f")})((!(!(!f))))}; } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } else { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'false'`)})(false)}; + {((cond) => {if (!cond) throw new Error("assertion failed: false")})(false)}; } } this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test",new $Closure1(this,"$Closure1")); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/static_members.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/static_members.w_compile_tf-aws.md index 84151f8725a..86805db4a85 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/static_members.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/static_members.w_compile_tf-aws.md @@ -14,8 +14,8 @@ module.exports = function({ }) { async handle() { const InflightClass = require("./inflight.InflightClass.js")({}); const inflightClass = new InflightClass(); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await inflightClass.inflightMethod()) === "Inflight method")'`)})(((await inflightClass.inflightMethod()) === "Inflight method"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await InflightClass.staticInflightMethod()) === "Static inflight method")'`)})(((await InflightClass.staticInflightMethod()) === "Static inflight method"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: inflightClass.inflightMethod() == \"Inflight method\"")})(((await inflightClass.inflightMethod()) === "Inflight method"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: InflightClass.staticInflightMethod() == \"Static inflight method\"")})(((await InflightClass.staticInflightMethod()) === "Static inflight method"))}; } } return $Closure1; @@ -265,8 +265,8 @@ class $Root extends $stdlib.std.Resource { } } const foo = new Foo(this,"Foo"); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(foo.instanceField === 100)'`)})((foo.instanceField === 100))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((Foo.m()) === 99)'`)})(((Foo.m()) === 99))}; + {((cond) => {if (!cond) throw new Error("assertion failed: foo.instanceField == 100")})((foo.instanceField === 100))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Foo.m() == 99")})(((Foo.m()) === 99))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test",new $Closure1(this,"$Closure1")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.w_compile_tf-aws.md index 937680878e9..4d7534ff4a4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.w_compile_tf-aws.md @@ -47,41 +47,41 @@ class $Root extends $stdlib.std.Resource { (mutArray.push("three")); const immutArray = Object.freeze([...(mutArray)]); const s = (sArray.at(1)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "two")'`)})((s === "two"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((sArray.at(1)) === "two")'`)})(((sArray.at(1)) === "two"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(sArray.length === 2)'`)})((sArray.length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(immutArray.length === 3)'`)})((immutArray.length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"two\"")})((s === "two"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: sArray.at(1) == \"two\"")})(((sArray.at(1)) === "two"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: sArray.length == 2")})((sArray.length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: immutArray.length == 3")})((immutArray.length === 3))}; const sArray2 = Object.freeze(["if", "you", "build", "it"]); const sArray3 = Object.freeze(["he", "will", "come", "for", "you"]); const mergedArray = (sArray2.concat(sArray3)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mergedArray.length === 9)'`)})((mergedArray.length === 9))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedArray.at(5)) === "will")'`)})(((mergedArray.at(5)) === "will"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 'mergedArray.includes("build")'`)})(mergedArray.includes("build"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!mergedArray.includes("bring"))'`)})((!mergedArray.includes("bring")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mergedArray.indexOf("you") === 1)'`)})((mergedArray.indexOf("you") === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedArray.join(" ")) === "if you build it he will come for you")'`)})(((mergedArray.join(" ")) === "if you build it he will come for you"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedArray.join()) === "if,you,build,it,he,will,come,for,you")'`)})(((mergedArray.join()) === "if,you,build,it,he,will,come,for,you"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mergedArray.lastIndexOf("you") === 8)'`)})((mergedArray.lastIndexOf("you") === 8))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.length == 9")})((mergedArray.length === 9))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.at(5) == \"will\"")})(((mergedArray.at(5)) === "will"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.contains(\"build\")")})(mergedArray.includes("build"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !mergedArray.contains(\"bring\")")})((!mergedArray.includes("bring")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.indexOf(\"you\") == 1")})((mergedArray.indexOf("you") === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.join(\" \") == \"if you build it he will come for you\"")})(((mergedArray.join(" ")) === "if you build it he will come for you"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.join() == \"if,you,build,it,he,will,come,for,you\"")})(((mergedArray.join()) === "if,you,build,it,he,will,come,for,you"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedArray.lastIndexOf(\"you\") == 8")})((mergedArray.lastIndexOf("you") === 8))}; const mutArray2 = ["how", "does", "that", "look"]; const mergedMutArray = (mutArray.concat(mutArray2)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(mergedMutArray.length === 7)'`)})((mergedMutArray.length === 7))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((mergedMutArray.at(5)) === "that")'`)})(((mergedMutArray.at(5)) === "that"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedMutArray.length == 7")})((mergedMutArray.length === 7))}; + {((cond) => {if (!cond) throw new Error("assertion failed: mergedMutArray.at(5) == \"that\"")})(((mergedMutArray.at(5)) === "that"))}; const sSet = Object.freeze(new Set(["one", "two"])); const mutSet = new Set(sSet); (mutSet.add("three")); const immutSet = Object.freeze(new Set(mutSet)); - {((cond) => {if (!cond) throw new Error(`assertion failed: '(sSet.has("one"))'`)})((sSet.has("one")))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(sSet.size === 2)'`)})((sSet.size === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(immutSet.size === 3)'`)})((immutSet.size === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: sSet.has(\"one\")")})((sSet.has("one")))}; + {((cond) => {if (!cond) throw new Error("assertion failed: sSet.size == 2")})((sSet.size === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: immutSet.size == 3")})((immutSet.size === 3))}; const sMap = Object.freeze({"one":1,"two":2}); const nestedMap = Object.freeze({"a":Object.freeze({"b":Object.freeze({"c":"hello"})})}); const mutMap = {...(sMap)}; ((obj, args) => { obj[args[0]] = args[1]; })(mutMap, ["five",5]); const immutMap = Object.freeze({...(mutMap)}); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((sMap)["one"] === 1)'`)})(((sMap)["one"] === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(sMap).length === 2)'`)})((Object.keys(sMap).length === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(Object.keys(immutMap).length === 3)'`)})((Object.keys(immutMap).length === 3))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((((nestedMap)["a"])["b"])["c"] === "hello")'`)})(((((nestedMap)["a"])["b"])["c"] === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: sMap.get(\"one\") == 1")})(((sMap)["one"] === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: sMap.size() == 2")})((Object.keys(sMap).length === 2))}; + {((cond) => {if (!cond) throw new Error("assertion failed: immutMap.size() == 3")})((Object.keys(immutMap).length === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: nestedMap.get(\"a\").get(\"b\").get(\"c\") == \"hello\"")})(((((nestedMap)["a"])["b"])["c"] === "hello"))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_string.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_string.w_compile_tf-aws.md index 1a75d8597e2..056e53bdae1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_string.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_string.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ s1, s2 }) { async $inflight_init() { } async handle() { - {console.log(`index of \"s\" in s1 is ${s1.indexOf("s")}`)}; + {console.log(String.raw({ raw: ["index of \"s\" in s1 is ", ""] }, s1.indexOf("s")))}; {console.log((await (await s1.split(" ")).at(1)))}; {console.log((await s1.concat(s2)))}; } @@ -195,21 +195,21 @@ class $Root extends $stdlib.std.Resource { } const s1 = "some string"; const s2 = "s are immutable"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s1.length === 11)'`)})((s1.length === 11))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((s1.at(7)) === "r")'`)})(((s1.at(7)) === "r"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((s1.concat(s2)) === "some strings are immutable")'`)})(((s1.concat(s2)) === "some strings are immutable"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 's1.includes("some")'`)})(s1.includes("some"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(!"some".includes(s1))'`)})((!"some".includes(s1)))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 's1.endsWith("string")'`)})(s1.endsWith("string"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s1.indexOf("s") === 0)'`)})((s1.indexOf("s") === 0))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("Some String".toLocaleLowerCase() === "some string")'`)})(("Some String".toLocaleLowerCase() === "some string"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(((s1.split(" ")).at(0)) === "some")'`)})((((s1.split(" ")).at(0)) === "some"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: 's1.startsWith("some")'`)})(s1.startsWith("some"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((s1.substring(5)) === "string")'`)})(((s1.substring(5)) === "string"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((s1.substring(5,7)) === "st")'`)})(((s1.substring(5,7)) === "st"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((" some string ".trim()) === "some string")'`)})(((" some string ".trim()) === "some string"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '("Some String".toLocaleUpperCase() === "SOME STRING")'`)})(("Some String".toLocaleUpperCase() === "SOME STRING"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(("hello" + " world") === "hello world")'`)})((("hello" + " world") === "hello world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.length == 11")})((s1.length === 11))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.at(7) == \"r\"")})(((s1.at(7)) === "r"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.concat(s2) == \"some strings are immutable\"")})(((s1.concat(s2)) === "some strings are immutable"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.contains(\"some\")")})(s1.includes("some"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: !\"some\".contains(s1)")})((!"some".includes(s1)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.endsWith(\"string\")")})(s1.endsWith("string"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.indexOf(\"s\") == 0")})((s1.indexOf("s") === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"Some String\".lowercase() == \"some string\"")})(("Some String".toLocaleLowerCase() === "some string"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.split(\" \").at(0) == \"some\"")})((((s1.split(" ")).at(0)) === "some"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.startsWith(\"some\")")})(s1.startsWith("some"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.substring(5) == \"string\"")})(((s1.substring(5)) === "string"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s1.substring(5, 7) == \"st\"")})(((s1.substring(5,7)) === "st"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \" some string \".trim() == \"some string\"")})(((" some string ".trim()) === "some string"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"Some String\".uppercase() == \"SOME STRING\"")})(("Some String".toLocaleUpperCase() === "SOME STRING"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: \"hello\" + \" world\" == \"hello world\"")})((("hello" + " world") === "hello world"))}; this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:string",new $Closure1(this,"$Closure1")); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/structs.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/structs.w_compile_tf-aws.md index 4c1f50de414..e914b721aae 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/structs.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/structs.w_compile_tf-aws.md @@ -107,9 +107,9 @@ class $Root extends $stdlib.std.Resource { "field0": "foo",} ,} ; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x.field0 === "Sup")'`)})((x.field0 === "Sup"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(y.field1 === 1)'`)})((y.field1 === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(y.field3.field0 === "foo")'`)})((y.field3.field0 === "foo"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x.field0 == \"Sup\"")})((x.field0 === "Sup"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y.field1 == 1")})((y.field1 === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: y.field3.field0 == \"foo\"")})((y.field3.field0 === "foo"))}; const s = { "a": "Boom baby",} ; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.w_compile_tf-aws.md index 241a09962a3..8c1a4128e23 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ s }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "inner")'`)})((s === "inner"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"inner\"")})((s === "inner"))}; } } return $Closure1; @@ -32,7 +32,7 @@ module.exports = function({ s }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "inResource")'`)})((s === "inResource"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"inResource\"")})((s === "inResource"))}; } } return $Closure2; @@ -52,7 +52,7 @@ module.exports = function({ s }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "top")'`)})((s === "top"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"top\"")})((s === "top"))}; } } return $Closure3; @@ -73,7 +73,7 @@ module.exports = function({ }) { } async handle() { const s = "insideInflight"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "insideInflight")'`)})((s === "insideInflight"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"insideInflight\"")})((s === "insideInflight"))}; } } return $Closure4; @@ -429,7 +429,7 @@ class $Root extends $stdlib.std.Resource { constructor(scope, id, ) { super(scope, id); const s = "inResource"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "inResource")'`)})((s === "inResource"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"inResource\"")})((s === "inResource"))}; const __parent_this_2 = this; class $Closure2 extends $stdlib.std.Resource { constructor(scope, id, ) { @@ -564,7 +564,7 @@ class $Root extends $stdlib.std.Resource { const s = "top"; if (true) { const s = "inner"; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "inner")'`)})((s === "inner"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"inner\"")})((s === "inner"))}; class $Closure1 extends $stdlib.std.Resource { constructor(scope, id, ) { super(scope, id); @@ -603,7 +603,7 @@ class $Root extends $stdlib.std.Resource { } this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:inflight nested should not capture the shadowed var",new $Closure1(this,"$Closure1")); } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(s === "top")'`)})((s === "top"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: s == \"top\"")})((s === "top"))}; new A(this,"A"); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:inflight on top should capture top",new $Closure3(this,"$Closure3")); this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:insideInflight should capture the right scope",new $Closure4(this,"$Closure4")); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.w_compile_tf-aws.md index a08b2444bf7..b0ea6cc1cdb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.w_compile_tf-aws.md @@ -12,9 +12,9 @@ module.exports = function({ b }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.list()).length === 0)'`)})(((await b.list()).length === 0))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.list().length == 0")})(((await b.list()).length === 0))}; (await b.put("hello.txt","world")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.list()).length === 1)'`)})(((await b.list()).length === 1))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.list().length == 1")})(((await b.list()).length === 1))}; } } return $Closure1; @@ -35,7 +35,7 @@ module.exports = function({ b }) { } async handle() { (await b.put("hello.txt","world")); - {((cond) => {if (!cond) throw new Error(`assertion failed: '((await b.get("hello.txt")) === "world")'`)})(((await b.get("hello.txt")) === "world"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: b.get(\"hello.txt\") == \"world\"")})(((await b.get("hello.txt")) === "world"))}; } } return $Closure2; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.w_compile_tf-aws.md index edf3c5964d5..3c356627ea5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.w_compile_tf-aws.md @@ -12,7 +12,7 @@ module.exports = function({ }) { async $inflight_init() { } async handle() { - {((cond) => {if (!cond) throw new Error(`assertion failed: 'true'`)})(true)}; + {((cond) => {if (!cond) throw new Error("assertion failed: true")})(true)}; } } return $Closure1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.w_compile_tf-aws.md index 110fb47c6f6..bbeb38e132d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.w_compile_tf-aws.md @@ -49,14 +49,14 @@ class $Root extends $stdlib.std.Resource { } catch ($error_e) { const e = $error_e.message; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(e === "hello")'`)})((e === "hello"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: e == \"hello\"")})((e === "hello"))}; x = "caught"; } finally { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === "caught")'`)})((x === "caught"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == \"caught\"")})((x === "caught"))}; x = "finally"; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === "finally")'`)})((x === "finally"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == \"finally\"")})((x === "finally"))}; try { x = "I got here"; } @@ -65,10 +65,10 @@ class $Root extends $stdlib.std.Resource { x = "caught"; } finally { - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === "I got here")'`)})((x === "I got here"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == \"I got here\"")})((x === "I got here"))}; x = "finally"; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === "finally")'`)})((x === "finally"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == \"finally\"")})((x === "finally"))}; try { try { {((msg) => {throw new Error(msg)})("hello")}; @@ -76,7 +76,7 @@ class $Root extends $stdlib.std.Resource { finally { x = "finally with no catch"; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === "finally with no catch")'`)})((x === "finally with no catch"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: x == \"finally with no catch\"")})((x === "finally with no catch"))}; } catch { } @@ -85,15 +85,8 @@ class $Root extends $stdlib.std.Resource { finally { x = "finally with no catch and no exception"; } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(x === "finally with no catch and no exception")'`)})((x === "finally with no catch and no exception"))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((( () => { - try { - } - finally { - return 1; - } - } - )()) === 1)'`)})(((( () => { + {((cond) => {if (!cond) throw new Error("assertion failed: x == \"finally with no catch and no exception\"")})((x === "finally with no catch and no exception"))}; + {((cond) => {if (!cond) throw new Error("assertion failed: (():num => { try {} finally {return 1;}})() == 1")})(((( () => { try { } finally { @@ -101,15 +94,7 @@ class $Root extends $stdlib.std.Resource { } } )()) === 1))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((( () => { - try { - {((msg) => {throw new Error(msg)})("")}; - } - catch { - return 2; - } - } - )()) === 2)'`)})(((( () => { + {((cond) => {if (!cond) throw new Error("assertion failed: (():num => { try {throw(\"\");} catch {return 2;}})() == 2")})(((( () => { try { {((msg) => {throw new Error(msg)})("")}; } @@ -118,14 +103,7 @@ class $Root extends $stdlib.std.Resource { } } )()) === 2))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '((( () => { - try { - return 3; - } - finally { - } - } - )()) === 3)'`)})(((( () => { + {((cond) => {if (!cond) throw new Error("assertion failed: (():num => { try {return 3;} finally {}})() == 3")})(((( () => { try { return 3; } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while.w_compile_tf-aws.md index 7bb62ac4401..60233f46c68 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while.w_compile_tf-aws.md @@ -56,7 +56,7 @@ class $Root extends $stdlib.std.Resource { break; } } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(z === 3)'`)})((z === 3))}; + {((cond) => {if (!cond) throw new Error("assertion failed: z == 3")})((z === 3))}; while (true) { break; } @@ -69,8 +69,8 @@ class $Root extends $stdlib.std.Resource { } v = (v + 1); } - {((cond) => {if (!cond) throw new Error(`assertion failed: '(i === 10)'`)})((i === 10))}; - {((cond) => {if (!cond) throw new Error(`assertion failed: '(v === 5)'`)})((v === 5))}; + {((cond) => {if (!cond) throw new Error("assertion failed: i == 10")})((i === 10))}; + {((cond) => {if (!cond) throw new Error("assertion failed: v == 5")})((v === 5))}; } } class $App extends $AppBase { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.w_compile_tf-aws.md index 770024ff115..bf5849074c8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.w_compile_tf-aws.md @@ -18,7 +18,7 @@ module.exports = function({ }) { } ; while (((await iterator(i)) < 3)) { - {console.log(`${i}`)}; + {console.log(String.raw({ raw: ["", ""] }, i))}; } } }