+15
-7
compiler-core/templates/echo.mjs
+15
-7
compiler-core/templates/echo.mjs
···
80
return "//js(circular reference)";
81
}
82
83
-
if (Array.isArray(v))
84
-
return `#(${v.map((v) => this.inspect(v)).join(", ")})`;
85
-
if (v instanceof $List) return this.#list(v);
86
-
if (v instanceof $CustomType) return this.#customType(v);
87
-
if (this.#isDict(v)) return this.#dict(v);
88
-
if (v instanceof Set)
89
return `//js(Set(${[...v].map((v) => this.inspect(v)).join(", ")}))`;
90
-
return this.#object(v);
91
}
92
93
#object(v) {
···
80
return "//js(circular reference)";
81
}
82
83
+
let printed;
84
+
if (Array.isArray(v)) {
85
+
printed = `#(${v.map((v) => this.inspect(v)).join(", ")})`;
86
+
} else if (v instanceof $List) {
87
+
printed = this.#list(v);
88
+
} else if (v instanceof $CustomType) {
89
+
printed = this.#customType(v);
90
+
} else if (this.#isDict(v)) {
91
+
printed = this.#dict(v);
92
+
} else if (v instanceof Set) {
93
return `//js(Set(${[...v].map((v) => this.inspect(v)).join(", ")}))`;
94
+
} else {
95
+
printed = this.#object(v);
96
+
}
97
+
this.#references.delete(v);
98
+
return printed;
99
}
100
101
#object(v) {
+3
test-output/cases/echo_singleton/gleam.toml
+3
test-output/cases/echo_singleton/gleam.toml
+11
test-output/cases/echo_singleton/src/main.gleam
+11
test-output/cases/echo_singleton/src/main.gleam
+7
test-output/cases/echo_singleton/src/main_ffi.mjs
+7
test-output/cases/echo_singleton/src/main_ffi.mjs
+5
test-output/src/tests/echo.rs
+5
test-output/src/tests/echo.rs
+23
test-output/src/tests/snapshots/test_output__tests__echo__echo_singleton.snap
+23
test-output/src/tests/snapshots/test_output__tests__echo__echo_singleton.snap
···
···
1
+
---
2
+
source: test-output/src/tests/echo.rs
3
+
assertion_line: 206
4
+
expression: output
5
+
snapshot_kind: text
6
+
---
7
+
--- main.gleam ----------------------
8
+
import thing
9
+
10
+
pub fn main() {
11
+
echo #(1, singleton(), singleton())
12
+
Nil
13
+
}
14
+
15
+
@external(javascript, "./main_ffi.mjs", "singleton")
16
+
fn singleton() -> thing.Thing {
17
+
thing.Thing
18
+
}
19
+
20
+
21
+
--- gleam run output ----------------
22
+
[90msrc/main.gleam:4[39m
23
+
#(1, Thing, Thing)