diff --git a/.trunk/configs/.prettierrc b/.trunk/configs/.prettierrc index 7497b18d2..fadc34a94 100644 --- a/.trunk/configs/.prettierrc +++ b/.trunk/configs/.prettierrc @@ -1,6 +1,6 @@ { "plugins": ["assemblyscript-prettier"], - "semi": false, + "semi": true, "proseWrap": "always", "printWidth": 100 } diff --git a/README.md b/README.md index 4f1be572d..acf7084de 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ You write a function. ```ts export function sayHello(name: string): string { - return `Hello, ${name}!` + return `Hello, ${name}!`; } ``` diff --git a/runtime/explorer/content/ModusIcon.tsx b/runtime/explorer/content/ModusIcon.tsx index 5e2326494..119704a8f 100644 --- a/runtime/explorer/content/ModusIcon.tsx +++ b/runtime/explorer/content/ModusIcon.tsx @@ -1,4 +1,4 @@ -import React from "react" +import React from "react"; const ModusLogo = ({ className }: { className?: string }) => ( @@ -29,6 +29,6 @@ const ModusLogo = ({ className }: { className?: string }) => ( /> -) +); -export default ModusLogo +export default ModusLogo; diff --git a/runtime/explorer/content/main.tsx b/runtime/explorer/content/main.tsx index 1c51e4d1c..559193510 100644 --- a/runtime/explorer/content/main.tsx +++ b/runtime/explorer/content/main.tsx @@ -1,15 +1,15 @@ -import React, { useEffect, useState } from "react" -import { createRoot } from "react-dom/client" -import { ApiExplorer } from "@hypermode/react-api-explorer" -import ModusIcon from "./ModusIcon" -import "@hypermode/react-api-explorer/styles.css" -import "./index.css" +import React, { useEffect, useState } from "react"; +import { createRoot } from "react-dom/client"; +import { ApiExplorer } from "@hypermode/react-api-explorer"; +import ModusIcon from "./ModusIcon"; +import "@hypermode/react-api-explorer/styles.css"; +import "./index.css"; -const rootElement = document.getElementById("root") +const rootElement = document.getElementById("root"); if (!rootElement) { - throw new Error("Root element not found") + throw new Error("Root element not found"); } -const root = createRoot(rootElement) +const root = createRoot(rootElement); function App() { const modusTheme = { @@ -32,29 +32,29 @@ function App() { border: "150 35% 17%", input: "150 35% 17%", ring: "150 60% 39%", - } - const [endpoints, setEndpoints] = useState(["http://localhost:8686/graphql"]) + }; + const [endpoints, setEndpoints] = useState(["http://localhost:8686/graphql"]); useEffect(() => { // Fetch endpoints when component mounts const fetchEndpoints = async () => { try { - const response = await fetch("/explorer/api/endpoints") - const data = await response.json() + const response = await fetch("/explorer/api/endpoints"); + const data = await response.json(); - const origin = window.location.origin + const origin = window.location.origin; const ep = data.map((endpoint: { path: string }) => { - return endpoint.path.startsWith("/") ? `${origin}${endpoint.path}` : endpoint.path - }) + return endpoint.path.startsWith("/") ? `${origin}${endpoint.path}` : endpoint.path; + }); - setEndpoints(ep) + setEndpoints(ep); } catch (error) { - console.error("Failed to fetch endpoints:", error) + console.error("Failed to fetch endpoints:", error); } - } + }; - fetchEndpoints() - }, []) + fetchEndpoints(); + }, []); return (
@@ -69,7 +69,7 @@ function App() { } />
- ) + ); } -root.render() +root.render(); diff --git a/runtime/explorer/content/postcss.config.js b/runtime/explorer/content/postcss.config.js index 2e7af2b7f..2aa7205d4 100644 --- a/runtime/explorer/content/postcss.config.js +++ b/runtime/explorer/content/postcss.config.js @@ -3,4 +3,4 @@ export default { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/runtime/explorer/content/tailwind.config.js b/runtime/explorer/content/tailwind.config.js index c6b6326c7..b4a0081b3 100644 --- a/runtime/explorer/content/tailwind.config.js +++ b/runtime/explorer/content/tailwind.config.js @@ -5,4 +5,4 @@ export default { extend: {}, }, plugins: [], -} +}; diff --git a/runtime/explorer/content/vite.config.ts b/runtime/explorer/content/vite.config.ts index ef9a83524..1a9c3d542 100644 --- a/runtime/explorer/content/vite.config.ts +++ b/runtime/explorer/content/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from "vite" -import react from "@vitejs/plugin-react" -import { resolve } from "path" +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import { resolve } from "path"; export default defineConfig({ plugins: [react()], @@ -26,4 +26,4 @@ export default defineConfig({ chunkSizeWarningLimit: 1000, }, base: "/explorer/", -}) +}); diff --git a/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts b/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts index 85f8e9a67..846e6b79e 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/arraybuffers.ts @@ -8,20 +8,20 @@ */ export function testArrayBufferInput(buffer: ArrayBuffer): void { - const view = Uint8Array.wrap(buffer) - assert(view.length == 4) - assert(view[0] == 1) - assert(view[1] == 2) - assert(view[2] == 3) - assert(view[3] == 4) + const view = Uint8Array.wrap(buffer); + assert(view.length == 4); + assert(view[0] == 1); + assert(view[1] == 2); + assert(view[2] == 3); + assert(view[3] == 4); } export function testArrayBufferOutput(): ArrayBuffer { - const buffer = new ArrayBuffer(4) - const view = Uint8Array.wrap(buffer) - view[0] = 1 - view[1] = 2 - view[2] = 3 - view[3] = 4 - return buffer + const buffer = new ArrayBuffer(4); + const view = Uint8Array.wrap(buffer); + view[0] = 1; + view[1] = 2; + view[2] = 3; + view[3] = 4; + return buffer; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/arrays.ts b/runtime/languages/assemblyscript/testdata/assembly/arrays.ts index f0bc8d85e..9254bd61c 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/arrays.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/arrays.ts @@ -8,79 +8,79 @@ */ export function testArrayOutput_i8(): i8[] { - return [1, 2, 3] + return [1, 2, 3]; } export function testArrayInput_i8(arr: i8[]): void { - assert(arr.length == 3) - assert(arr[0] == 1) - assert(arr[1] == 2) - assert(arr[2] == 3) + assert(arr.length == 3); + assert(arr[0] == 1); + assert(arr[1] == 2); + assert(arr[2] == 3); } export function testArrayOutput_i8_empty(): i8[] { - return [] + return []; } export function testArrayInput_i8_empty(arr: i8[]): void { - assert(arr.length == 0) + assert(arr.length == 0); } export function testArrayOutput_i8_null(): i8[] | null { - return null + return null; } export function testArrayInput_i8_null(arr: i8[] | null): void { - assert(arr == null) + assert(arr == null); } export function testArrayInput_i32(arr: i32[]): void { - assert(arr.length == 3) - assert(arr[0] == 1) - assert(arr[1] == 2) - assert(arr[2] == 3) + assert(arr.length == 3); + assert(arr[0] == 1); + assert(arr[1] == 2); + assert(arr[2] == 3); } export function testArrayOutput_i32(): i32[] { - return [1, 2, 3] + return [1, 2, 3]; } export function testArrayInput_f32(arr: f32[]): void { - assert(arr.length == 3) - assert(arr[0] == 1) - assert(arr[1] == 2) - assert(arr[2] == 3) + assert(arr.length == 3); + assert(arr[0] == 1); + assert(arr[1] == 2); + assert(arr[2] == 3); } export function testArrayOutput_f32(): f32[] { - return [1, 2, 3] + return [1, 2, 3]; } export function testArrayInput_string(arr: string[]): void { - assert(arr.length == 3) - assert(arr[0] == "abc") - assert(arr[1] == "def") - assert(arr[2] == "ghi") + assert(arr.length == 3); + assert(arr[0] == "abc"); + assert(arr[1] == "def"); + assert(arr[2] == "ghi"); } export function testArrayOutput_string(): string[] { - return ["abc", "def", "ghi"] + return ["abc", "def", "ghi"]; } export function testArrayInput_string_2d(arr: string[][]): void { - assert(arr.length == 3) - assert(arr[0].length == 3) - assert(arr[0][0] == "abc") - assert(arr[0][1] == "def") - assert(arr[0][2] == "ghi") - assert(arr[1].length == 3) - assert(arr[1][0] == "jkl") - assert(arr[1][1] == "mno") - assert(arr[1][2] == "pqr") - assert(arr[2].length == 3) - assert(arr[2][0] == "stu") - assert(arr[2][1] == "vwx") - assert(arr[2][2] == "yz") + assert(arr.length == 3); + assert(arr[0].length == 3); + assert(arr[0][0] == "abc"); + assert(arr[0][1] == "def"); + assert(arr[0][2] == "ghi"); + assert(arr[1].length == 3); + assert(arr[1][0] == "jkl"); + assert(arr[1][1] == "mno"); + assert(arr[1][2] == "pqr"); + assert(arr[2].length == 3); + assert(arr[2][0] == "stu"); + assert(arr[2][1] == "vwx"); + assert(arr[2][2] == "yz"); } export function testArrayOutput_string_2d(): string[][] { @@ -88,15 +88,15 @@ export function testArrayOutput_string_2d(): string[][] { ["abc", "def", "ghi"], ["jkl", "mno", "pqr"], ["stu", "vwx", "yz"], - ] + ]; } export function testArrayInput_string_2d_empty(arr: string[][]): void { - assert(arr.length == 0) + assert(arr.length == 0); } export function testArrayOutput_string_2d_empty(): string[][] { - return [] + return []; } class TestObject1 { @@ -108,7 +108,7 @@ class TestObject1 { export function testArrayIteration(arr: TestObject1[]): void { for (let i = 0; i < arr.length; i++) { - let obj = arr[i] - console.log(`[${i}]: a=${obj.a}, b=${obj.b}`) + let obj = arr[i]; + console.log(`[${i}]: a=${obj.a}, b=${obj.b}`); } } diff --git a/runtime/languages/assemblyscript/testdata/assembly/classes.ts b/runtime/languages/assemblyscript/testdata/assembly/classes.ts index 1b452b721..4125e4d69 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/classes.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/classes.ts @@ -8,191 +8,191 @@ */ class TestClass1 { - a!: bool + a!: bool; } class TestClass1_map { - a!: bool + a!: bool; } class TestClass2 { - a!: bool - b!: isize + a!: bool; + b!: isize; } class TestClass2_map { - a!: bool - b!: isize + a!: bool; + b!: isize; } class TestClass3 { - a!: bool - b!: isize - c!: string + a!: bool; + b!: isize; + c!: string; } class TestClass3_map { - a!: bool - b!: isize - c!: string + a!: bool; + b!: isize; + c!: string; } class TestClass4 { - a!: bool - b!: isize - c!: string | null + a!: bool; + b!: isize; + c!: string | null; } class TestClass4_map { - a!: bool - b!: isize - c!: string | null + a!: bool; + b!: isize; + c!: string | null; } class TestClass5 { - a!: bool - b!: TestClass3 + a!: bool; + b!: TestClass3; } class TestClass5_map { - a!: bool - b!: TestClass3_map + a!: bool; + b!: TestClass3_map; } class TestRecursiveClass { - a!: bool - b!: TestRecursiveClass | null + a!: bool; + b!: TestRecursiveClass | null; } class TestRecursiveClass_map { - a!: bool - b!: TestRecursiveClass_map | null + a!: bool; + b!: TestRecursiveClass_map | null; } -const testClass1 = { a: true } -const testClass2 = { a: true, b: 123 } -const testClass3 = { a: true, b: 123, c: "abc" } -const testClass4 = { a: true, b: 123, c: "abc" } -const testClass4_withNull = { a: true, b: 123, c: null } -const testClass5 = { a: true, b: testClass3 } +const testClass1 = { a: true }; +const testClass2 = { a: true, b: 123 }; +const testClass3 = { a: true, b: 123, c: "abc" }; +const testClass4 = { a: true, b: 123, c: "abc" }; +const testClass4_withNull = { a: true, b: 123, c: null }; +const testClass5 = { a: true, b: testClass3 }; -const testRecursiveClass = { a: true } -testRecursiveClass.b = testRecursiveClass +const testRecursiveClass = { a: true }; +testRecursiveClass.b = testRecursiveClass; -const testClass1_map = { a: true } -const testClass2_map = { a: true, b: 123 } -const testClass3_map = { a: true, b: 123, c: "abc" } -const testClass4_map = { a: true, b: 123, c: "abc" } -const testClass4_map_withNull = { a: true, b: 123, c: null } -const testClass5_map = { a: true, b: testClass3_map } +const testClass1_map = { a: true }; +const testClass2_map = { a: true, b: 123 }; +const testClass3_map = { a: true, b: 123, c: "abc" }; +const testClass4_map = { a: true, b: 123, c: "abc" }; +const testClass4_map_withNull = { a: true, b: 123, c: null }; +const testClass5_map = { a: true, b: testClass3_map }; -const testRecursiveClass_map = { a: true } -testRecursiveClass_map.b = testRecursiveClass_map +const testRecursiveClass_map = { a: true }; +testRecursiveClass_map.b = testRecursiveClass_map; export function testClassInput1(o: TestClass1): void { - assert(o.a == testClass1.a) + assert(o.a == testClass1.a); } export function testClassOutput1(): TestClass1 { - return testClass1 + return testClass1; } export function testClassOutput1_map(): TestClass1_map { - return testClass1_map + return testClass1_map; } export function testClassInput2(o: TestClass2): void { - assert(o.a == testClass2.a) - assert(o.b == testClass2.b) + assert(o.a == testClass2.a); + assert(o.b == testClass2.b); } export function testClassOutput2(): TestClass2 { - return testClass2 + return testClass2; } export function testClassOutput2_map(): TestClass2_map { - return testClass2_map + return testClass2_map; } export function testClassInput3(o: TestClass3): void { - assert(o.a == testClass3.a) - assert(o.b == testClass3.b) - assert(o.c == testClass3.c) + assert(o.a == testClass3.a); + assert(o.b == testClass3.b); + assert(o.c == testClass3.c); } export function testClassOutput3(): TestClass3 { - return testClass3 + return testClass3; } export function testClassOutput3_map(): TestClass3_map { - return testClass3_map + return testClass3_map; } export function testClassInput4_withNull(o: TestClass4): void { - assert(o.a == testClass4_withNull.a) - assert(o.b == testClass4_withNull.b) - assert(o.c == testClass4_withNull.c) + assert(o.a == testClass4_withNull.a); + assert(o.b == testClass4_withNull.b); + assert(o.c == testClass4_withNull.c); } export function testClassOutput4(): TestClass4 { - return testClass4 + return testClass4; } export function testClassOutput4_map(): TestClass4_map { - return testClass4_map + return testClass4_map; } export function testClassInput4(o: TestClass4): void { - assert(o.a == testClass4.a) - assert(o.b == testClass4.b) - assert(o.c == testClass4.c) + assert(o.a == testClass4.a); + assert(o.b == testClass4.b); + assert(o.c == testClass4.c); } export function testClassOutput4_withNull(): TestClass4 { - return testClass4_withNull + return testClass4_withNull; } export function testClassOutput4_map_withNull(): TestClass4_map { - return testClass4_map_withNull + return testClass4_map_withNull; } export function testClassInput5(o: TestClass5): void { - assert(o.a == testClass5.a) - assert(o.b.a == testClass5.b.a) - assert(o.b.b == testClass5.b.b) - assert(o.b.c == testClass5.b.c) + assert(o.a == testClass5.a); + assert(o.b.a == testClass5.b.a); + assert(o.b.b == testClass5.b.b); + assert(o.b.c == testClass5.b.c); } export function testClassOutput5(): TestClass5 { - return testClass5 + return testClass5; } export function testClassOutput5_map(): TestClass5_map { - return testClass5_map + return testClass5_map; } export function testRecursiveClassInput(o: TestRecursiveClass): void { - assert(o.a == testRecursiveClass.a) - assert(o.b == testRecursiveClass.b) + assert(o.a == testRecursiveClass.a); + assert(o.b == testRecursiveClass.b); } export function testRecursiveClassOutput(): TestRecursiveClass { - return testRecursiveClass + return testRecursiveClass; } export function testNullableClassInput1(o: TestClass1 | null): void { - assert(o != null) - assert(o!.a == testClass1.a) + assert(o != null); + assert(o!.a == testClass1.a); } export function testNullableClassOutput1(): TestClass1 | null { - return testClass1 + return testClass1; } export function testNullableClassInput1_null(o: TestClass1 | null): void { - assert(o == null) + assert(o == null); } export function testNullableClassOutput1_null(): TestClass1 | null { - return null + return null; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/dates.ts b/runtime/languages/assemblyscript/testdata/assembly/dates.ts index 86bbcca5f..5e199f1b6 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/dates.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/dates.ts @@ -7,32 +7,32 @@ * SPDX-License-Identifier: Apache-2.0 */ -const testTime = Date.parse("2024-12-31T23:59:59.999Z").getTime() +const testTime = Date.parse("2024-12-31T23:59:59.999Z").getTime(); export function testDateInput(d: Date): void { - const ts = d.getTime() - assert(ts == testTime, `Expected ${testTime}, got ${ts}`) + const ts = d.getTime(); + assert(ts == testTime, `Expected ${testTime}, got ${ts}`); } export function testDateOutput(): Date { - return new Date(testTime) + return new Date(testTime); } export function testNullDateInput(d: Date | null): void { - assert(d != null, `Expected non-null, got null`) + assert(d != null, `Expected non-null, got null`); - const ts = d!.getTime() - assert(ts == testTime, `Expected ${testTime}, got ${ts}`) + const ts = d!.getTime(); + assert(ts == testTime, `Expected ${testTime}, got ${ts}`); } export function testNullDateOutput(): Date | null { - return new Date(testTime) + return new Date(testTime); } export function testNullDateInput_null(d: Date | null): void { - assert(d == null, `Expected null, got ${d!.getTime()}`) + assert(d == null, `Expected null, got ${d!.getTime()}`); } export function testNullDateOutput_null(): Date | null { - return null + return null; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/env.ts b/runtime/languages/assemblyscript/testdata/assembly/env.ts index 1242b44f7..9b96fef4f 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/env.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/env.ts @@ -8,18 +8,18 @@ */ export function now(): i64 { - return Date.now() + return Date.now(); } export function spin(duration: i64): i64 { - const start = performance.now() + const start = performance.now(); - let d = Date.now() + let d = Date.now(); while (Date.now() - d <= duration) { // do nothing } - const end = performance.now() + const end = performance.now(); - return i64(end - start) + return i64(end - start); } diff --git a/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts b/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts index 4936eefe4..fa7eefa6a 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/hostfns.ts @@ -9,30 +9,30 @@ // @ts-expect-error: decorator @external("modus_test", "add") -declare function hostAdd(a: i32, b: i32): i32 +declare function hostAdd(a: i32, b: i32): i32; // @ts-expect-error: decorator @external("modus_test", "echo") -declare function hostEcho(message: string): string +declare function hostEcho(message: string): string; // @ts-expect-error: decorator @external("modus_test", "echoObject") -declare function hostEchoObject(obj: TestHostObject): TestHostObject +declare function hostEchoObject(obj: TestHostObject): TestHostObject; class TestHostObject { - a!: i32 - b!: bool - c!: string + a!: i32; + b!: bool; + c!: string; } export function add(a: i32, b: i32): i32 { - return hostAdd(a, b) + return hostAdd(a, b); } export function echo(message: string): string { - return hostEcho(message) + return hostEcho(message); } export function echoObject(obj: TestHostObject): TestHostObject { - return hostEchoObject(obj) + return hostEchoObject(obj); } diff --git a/runtime/languages/assemblyscript/testdata/assembly/index.ts b/runtime/languages/assemblyscript/testdata/assembly/index.ts index 552217bf6..f22035389 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/index.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/index.ts @@ -7,13 +7,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -export * from "./arrays" -export * from "./arraybuffers" -export * from "./classes" -export * from "./dates" -export * from "./env" -export * from "./hostfns" -export * from "./maps" -export * from "./primitives" -export * from "./strings" -export * from "./typedarrays" +export * from "./arrays"; +export * from "./arraybuffers"; +export * from "./classes"; +export * from "./dates"; +export * from "./env"; +export * from "./hostfns"; +export * from "./maps"; +export * from "./primitives"; +export * from "./strings"; +export * from "./typedarrays"; diff --git a/runtime/languages/assemblyscript/testdata/assembly/maps.ts b/runtime/languages/assemblyscript/testdata/assembly/maps.ts index a1995d708..385a0a6bf 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/maps.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/maps.ts @@ -8,147 +8,147 @@ */ export function testMapInput_u8_string(m: Map): void { - assert(m.size == 3, "expected size 3") + assert(m.size == 3, "expected size 3"); - assert(m.has(1), "expected key 1 to be present") - assert(m.get(1) == "a", "expected value for key 1 to be 'a'") + assert(m.has(1), "expected key 1 to be present"); + assert(m.get(1) == "a", "expected value for key 1 to be 'a'"); - assert(m.has(2), "expected key 2 to be present") - assert(m.get(2) == "b", "expected value for key 2 to be 'b'") + assert(m.has(2), "expected key 2 to be present"); + assert(m.get(2) == "b", "expected value for key 2 to be 'b'"); - assert(m.has(3), "expected key 3 to be present") - assert(m.get(3) == "c", "expected value for key 3 to be 'c'") + assert(m.has(3), "expected key 3 to be present"); + assert(m.get(3) == "c", "expected value for key 3 to be 'c'"); } export function testMapOutput_u8_string(): Map { - const m = new Map() - m.set(1, "a") - m.set(2, "b") - m.set(3, "c") - return m + const m = new Map(); + m.set(1, "a"); + m.set(2, "b"); + m.set(3, "c"); + return m; } export function testMapInput_string_string(m: Map): void { - assert(m.size == 3, "expected size 3") + assert(m.size == 3, "expected size 3"); - assert(m.has("a"), "expected key 'a' to be present") - assert(m.get("a") == "1", "expected value for key 'a' to be '1'") + assert(m.has("a"), "expected key 'a' to be present"); + assert(m.get("a") == "1", "expected value for key 'a' to be '1'"); - assert(m.has("b"), "expected key 'b' to be present") - assert(m.get("b") == "2", "expected value for key 'b' to be '2'") + assert(m.has("b"), "expected key 'b' to be present"); + assert(m.get("b") == "2", "expected value for key 'b' to be '2'"); - assert(m.has("c"), "expected key 'c' to be present") - assert(m.get("c") == "3", "expected value for key 'c' to be '3'") + assert(m.has("c"), "expected key 'c' to be present"); + assert(m.get("c") == "3", "expected value for key 'c' to be '3'"); } export function testMapOutput_string_string(): Map { - const m = new Map() - m.set("a", "1") - m.set("b", "2") - m.set("c", "3") - return m + const m = new Map(); + m.set("a", "1"); + m.set("b", "2"); + m.set("c", "3"); + return m; } export function testNullableMapInput_string_string(m: Map | null): void { - assert(m != null, "expected non-null map") - assert(m!.size == 3, "expected size 3") + assert(m != null, "expected non-null map"); + assert(m!.size == 3, "expected size 3"); - assert(m!.has("a"), "expected key 'a' to be present") - assert(m!.get("a") == "1", "expected value for key 'a' to be '1'") + assert(m!.has("a"), "expected key 'a' to be present"); + assert(m!.get("a") == "1", "expected value for key 'a' to be '1'"); - assert(m!.has("b"), "expected key 'b' to be present") - assert(m!.get("b") == "2", "expected value for key 'b' to be '2'") + assert(m!.has("b"), "expected key 'b' to be present"); + assert(m!.get("b") == "2", "expected value for key 'b' to be '2'"); - assert(m!.has("c"), "expected key 'c' to be present") - assert(m!.get("c") == "3", "expected value for key 'c' to be '3'") + assert(m!.has("c"), "expected key 'c' to be present"); + assert(m!.get("c") == "3", "expected value for key 'c' to be '3'"); } export function testNullableMapInput_string_string_null(m: Map | null): void { - assert(m == null, "expected null map") + assert(m == null, "expected null map"); } export function testNullableMapOutput_string_string(): Map | null { - const m = new Map() - m.set("a", "1") - m.set("b", "2") - m.set("c", "3") - return m + const m = new Map(); + m.set("a", "1"); + m.set("b", "2"); + m.set("c", "3"); + return m; } export function testNullableMapOutput_string_string_null(): Map | null { - return null + return null; } export function testIterateMap_string_string(m: Map): void { - const keys = m.keys() - const values = m.values() + const keys = m.keys(); + const values = m.values(); for (let i = 0; i < m.size; i++) { - const key = keys[i] - const value = values[i] - console.log(key + " => " + value) + const key = keys[i]; + const value = values[i]; + console.log(key + " => " + value); } } export function testMapLookup_string_string(m: Map, key: string): string | null { if (m.has(key)) { - return m.get(key) + return m.get(key); } - return null + return null; } class TestClassWithMap { - m!: Map + m!: Map; } export function testClassContainingMapInput_string_string(c: TestClassWithMap): void { - assert(c != null, "expected non-null class") - assert(c.m != null, "expected non-null map") - assert(c.m.size == 3, "expected size 3") + assert(c != null, "expected non-null class"); + assert(c.m != null, "expected non-null map"); + assert(c.m.size == 3, "expected size 3"); - assert(c.m.has("a"), "expected key 'a' to be present") - assert(c.m.get("a") == "1", "expected value for key 'a' to be '1'") + assert(c.m.has("a"), "expected key 'a' to be present"); + assert(c.m.get("a") == "1", "expected value for key 'a' to be '1'"); - assert(c.m.has("b"), "expected key 'b' to be present") - assert(c.m.get("b") == "2", "expected value for key 'b' to be '2'") + assert(c.m.has("b"), "expected key 'b' to be present"); + assert(c.m.get("b") == "2", "expected value for key 'b' to be '2'"); - assert(c.m.has("c"), "expected key 'c' to be present") - assert(c.m.get("c") == "3", "expected value for key 'c' to be '3'") + assert(c.m.has("c"), "expected key 'c' to be present"); + assert(c.m.get("c") == "3", "expected value for key 'c' to be '3'"); } export function testClassContainingMapOutput_string_string(): TestClassWithMap { - const c = new TestClassWithMap() - c.m = new Map() - c.m.set("a", "1") - c.m.set("b", "2") - c.m.set("c", "3") - return c + const c = new TestClassWithMap(); + c.m = new Map(); + c.m.set("a", "1"); + c.m.set("b", "2"); + c.m.set("c", "3"); + return c; } export function testMapInput_string_f64(m: Map): void { - assert(m.size == 4, "expected size 4") + assert(m.size == 4, "expected size 4"); - let n: f64 = 0.5 - assert(m.has("a"), "expected key 'a' to be present") - assert(m.get("a") == n, `expected value for key 'a' to be ${n}`) + let n: f64 = 0.5; + assert(m.has("a"), "expected key 'a' to be present"); + assert(m.get("a") == n, `expected value for key 'a' to be ${n}`); - n = f64.EPSILON - assert(m.has("b"), "expected key 'b' to be present") - assert(m.get("b") == n, `expected value for key 'b' to be ${n}`) + n = f64.EPSILON; + assert(m.has("b"), "expected key 'b' to be present"); + assert(m.get("b") == n, `expected value for key 'b' to be ${n}`); - n = f64.MIN_VALUE - assert(m.has("c"), "expected key 'c' to be present") - assert(m.get("c") == n, `expected value for key 'c' to be ${n}`) + n = f64.MIN_VALUE; + assert(m.has("c"), "expected key 'c' to be present"); + assert(m.get("c") == n, `expected value for key 'c' to be ${n}`); - n = f64.MAX_VALUE - assert(m.has("d"), "expected key 'd' to be present") - assert(m.get("d") == n, `expected value for key 'd' to be ${n}`) + n = f64.MAX_VALUE; + assert(m.has("d"), "expected key 'd' to be present"); + assert(m.get("d") == n, `expected value for key 'd' to be ${n}`); } export function testMapOutput_string_f64(): Map { - const m = new Map() - m.set("a", 0.5) - m.set("b", f64.EPSILON) - m.set("c", f64.MIN_VALUE) - m.set("d", f64.MAX_VALUE) - return m + const m = new Map(); + m.set("a", 0.5); + m.set("b", f64.EPSILON); + m.set("c", f64.MIN_VALUE); + m.set("d", f64.MAX_VALUE); + return m; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/primitives.ts b/runtime/languages/assemblyscript/testdata/assembly/primitives.ts index 264166388..ecb317be6 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/primitives.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/primitives.ts @@ -8,209 +8,209 @@ */ export function testBoolInput_false(b: bool): void { - assert(b == false) + assert(b == false); } export function testBoolInput_true(b: bool): void { - assert(b == true) + assert(b == true); } export function testBoolOutput_false(): bool { - return false + return false; } export function testBoolOutput_true(): bool { - return true + return true; } export function testI8Input_min(n: i8): void { - assert(n == i8.MIN_VALUE) + assert(n == i8.MIN_VALUE); } export function testI8Input_max(n: i8): void { - assert(n == i8.MAX_VALUE) + assert(n == i8.MAX_VALUE); } export function testI8Output_min(): i8 { - return i8.MIN_VALUE + return i8.MIN_VALUE; } export function testI8Output_max(): i8 { - return i8.MAX_VALUE + return i8.MAX_VALUE; } export function testI16Input_min(n: i16): void { - assert(n == i16.MIN_VALUE) + assert(n == i16.MIN_VALUE); } export function testI16Input_max(n: i16): void { - assert(n == i16.MAX_VALUE) + assert(n == i16.MAX_VALUE); } export function testI16Output_min(): i16 { - return i16.MIN_VALUE + return i16.MIN_VALUE; } export function testI16Output_max(): i16 { - return i16.MAX_VALUE + return i16.MAX_VALUE; } export function testI32Input_min(n: i32): void { - assert(n == i32.MIN_VALUE) + assert(n == i32.MIN_VALUE); } export function testI32Input_max(n: i32): void { - assert(n == i32.MAX_VALUE) + assert(n == i32.MAX_VALUE); } export function testI32Output_min(): i32 { - return i32.MIN_VALUE + return i32.MIN_VALUE; } export function testI32Output_max(): i32 { - return i32.MAX_VALUE + return i32.MAX_VALUE; } export function testI64Input_min(n: i64): void { - assert(n == i64.MIN_VALUE) + assert(n == i64.MIN_VALUE); } export function testI64Input_max(n: i64): void { - assert(n == i64.MAX_VALUE) + assert(n == i64.MAX_VALUE); } export function testI64Output_min(): i64 { - return i64.MIN_VALUE + return i64.MIN_VALUE; } export function testI64Output_max(): i64 { - return i64.MAX_VALUE + return i64.MAX_VALUE; } export function testISizeInput_min(n: isize): void { - assert(n == isize.MIN_VALUE) + assert(n == isize.MIN_VALUE); } export function testISizeInput_max(n: isize): void { - assert(n == isize.MAX_VALUE) + assert(n == isize.MAX_VALUE); } export function testISizeOutput_min(): isize { - return isize.MIN_VALUE + return isize.MIN_VALUE; } export function testISizeOutput_max(): isize { - return isize.MAX_VALUE + return isize.MAX_VALUE; } export function testU8Input_min(n: u8): void { - assert(n == u8.MIN_VALUE) + assert(n == u8.MIN_VALUE); } export function testU8Input_max(n: u8): void { - assert(n == u8.MAX_VALUE) + assert(n == u8.MAX_VALUE); } export function testU8Output_min(): u8 { - return u8.MIN_VALUE + return u8.MIN_VALUE; } export function testU8Output_max(): u8 { - return u8.MAX_VALUE + return u8.MAX_VALUE; } export function testU16Input_min(n: u16): void { - assert(n == u16.MIN_VALUE) + assert(n == u16.MIN_VALUE); } export function testU16Input_max(n: u16): void { - assert(n == u16.MAX_VALUE) + assert(n == u16.MAX_VALUE); } export function testU16Output_min(): u16 { - return u16.MIN_VALUE + return u16.MIN_VALUE; } export function testU16Output_max(): u16 { - return u16.MAX_VALUE + return u16.MAX_VALUE; } export function testU32Input_min(n: u32): void { - assert(n == u32.MIN_VALUE) + assert(n == u32.MIN_VALUE); } export function testU32Input_max(n: u32): void { - assert(n == u32.MAX_VALUE) + assert(n == u32.MAX_VALUE); } export function testU32Output_min(): u32 { - return u32.MIN_VALUE + return u32.MIN_VALUE; } export function testU32Output_max(): u32 { - return u32.MAX_VALUE + return u32.MAX_VALUE; } export function testU64Input_min(n: u64): void { - assert(n == u64.MIN_VALUE) + assert(n == u64.MIN_VALUE); } export function testU64Input_max(n: u64): void { - assert(n == u64.MAX_VALUE) + assert(n == u64.MAX_VALUE); } export function testU64Output_min(): u64 { - return u64.MIN_VALUE + return u64.MIN_VALUE; } export function testU64Output_max(): u64 { - return u64.MAX_VALUE + return u64.MAX_VALUE; } export function testUSizeInput_min(n: usize): void { - assert(n == usize.MIN_VALUE) + assert(n == usize.MIN_VALUE); } export function testUSizeInput_max(n: usize): void { - assert(n == usize.MAX_VALUE) + assert(n == usize.MAX_VALUE); } export function testUSizeOutput_min(): usize { - return usize.MIN_VALUE + return usize.MIN_VALUE; } export function testUSizeOutput_max(): usize { - return usize.MAX_VALUE + return usize.MAX_VALUE; } export function testF32Input_min(n: f32): void { - assert(n == f32.MIN_VALUE) + assert(n == f32.MIN_VALUE); } export function testF32Input_max(n: f32): void { - assert(n == f32.MAX_VALUE) + assert(n == f32.MAX_VALUE); } export function testF32Output_min(): f32 { - return f32.MIN_VALUE + return f32.MIN_VALUE; } export function testF32Output_max(): f32 { - return f32.MAX_VALUE + return f32.MAX_VALUE; } export function testF64Input_min(n: f64): void { - assert(n == f64.MIN_VALUE) + assert(n == f64.MIN_VALUE); } export function testF64Input_max(n: f64): void { - assert(n == f64.MAX_VALUE) + assert(n == f64.MAX_VALUE); } export function testF64Output_min(): f64 { - return f64.MIN_VALUE + return f64.MIN_VALUE; } export function testF64Output_max(): f64 { - return f64.MAX_VALUE + return f64.MAX_VALUE; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/strings.ts b/runtime/languages/assemblyscript/testdata/assembly/strings.ts index ca77b3986..7de9085e0 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/strings.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/strings.ts @@ -8,44 +8,44 @@ */ // "Hello World" in Japanese -const testString = "こんにちは、世界" +const testString = "こんにちは、世界"; export function testStringInput(s: string): void { - assert(s == testString) + assert(s == testString); } export function testStringOutput(): string { - return testString + return testString; } export function testStringInput_empty(s: string): void { - assert(s == "") + assert(s == ""); } export function testStringOutput_empty(): string { - return "" + return ""; } export function testNullStringInput(s: string | null): void { - assert(s == testString) + assert(s == testString); } export function testNullStringOutput(): string | null { - return testString + return testString; } export function testNullStringInput_empty(s: string | null): void { - assert(s == "") + assert(s == ""); } export function testNullStringOutput_empty(): string | null { - return "" + return ""; } export function testNullStringInput_null(s: string | null): void { - assert(s == null) + assert(s == null); } export function testNullStringOutput_null(): string | null { - return null + return null; } diff --git a/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts b/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts index 96d4ccf00..895966fc1 100644 --- a/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts +++ b/runtime/languages/assemblyscript/testdata/assembly/typedarrays.ts @@ -8,171 +8,171 @@ */ export function testInt8ArrayInput(view: Int8Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt8ArrayOutput(): Int8Array { - const view = new Int8Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int8Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testInt16ArrayInput(view: Int16Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt16ArrayOutput(): Int16Array { - const view = new Int16Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int16Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testInt32ArrayInput(view: Int32Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt32ArrayOutput(): Int32Array { - const view = new Int32Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int32Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testInt64ArrayInput(view: Int64Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testInt64ArrayOutput(): Int64Array { - const view = new Int64Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Int64Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint8ArrayInput(view: Uint8Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint8ArrayInput_empty(view: Uint8Array): void { - assert(view.length == 0) + assert(view.length == 0); } export function testUint8ArrayInput_null(view: Uint8Array | null): void { - assert(view == null) + assert(view == null); } export function testUint8ArrayOutput(): Uint8Array { - const view = new Uint8Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint8Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint8ArrayOutput_empty(): Uint8Array { - return new Uint8Array(0) + return new Uint8Array(0); } export function testUint8ArrayOutput_null(): Uint8Array | null { - return null + return null; } export function testUint8ClampedArrayInput(view: Uint8ClampedArray): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint8ClampedArrayOutput(): Uint8ClampedArray { - const view = new Uint8ClampedArray(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint8ClampedArray(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint16ArrayInput(view: Uint16Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint16ArrayOutput(): Uint16Array { - const view = new Uint16Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint16Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint32ArrayInput(view: Uint32Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint32ArrayOutput(): Uint32Array { - const view = new Uint32Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint32Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testUint64ArrayInput(view: Uint64Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testUint64ArrayOutput(): Uint64Array { - const view = new Uint64Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Uint64Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testFloat32ArrayInput(view: Float32Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testFloat32ArrayOutput(): Float32Array { - const view = new Float32Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Float32Array(4); + view.set([0, 1, 2, 3]); + return view; } export function testFloat64ArrayInput(view: Float64Array): void { - assert(view.length == 4) - assert(view[0] == 0) - assert(view[1] == 1) - assert(view[2] == 2) - assert(view[3] == 3) + assert(view.length == 4); + assert(view[0] == 0); + assert(view[1] == 1); + assert(view[2] == 2); + assert(view[3] == 3); } export function testFloat64ArrayOutput(): Float64Array { - const view = new Float64Array(4) - view.set([0, 1, 2, 3]) - return view + const view = new Float64Array(4); + view.set([0, 1, 2, 3]); + return view; }