Skip to content

Commit

Permalink
Remove $ syntax handling and related tests
Browse files Browse the repository at this point in the history
* **src/index.ts**
  - Remove `$` syntax handling from `getExe` and `exeOp` functions
  - Bump version to 241030

* **src/web.ts**
  - Remove `$` syntax handling from `set`, `get`, and `exe` functions

* **README.md**
  - Remove mention of `$` get/set syntax from "Coding in Insitux" section
  - Remove example using `$` syntax from "Various examples" section
  - Remove advisory for integration support of `$`

* **package.json** and **package-lock.json**
  - Bump version to 24.10.30

* **src/test.ts**
  - Remove tests related to `$`
  • Loading branch information
phunanon committed Nov 7, 2024
1 parent c2fa7ae commit 4d2dd7c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { concat, round, getTimeMs, len, padEnd, trim } from "./poly-fills";
import { Ctx, Env, Val, ValOrErr, InvokeResult } from "./types";

type State = { output: string };
type State = { dict: Map<string, Val>; output: string };

function get(state: State, key: string): ValOrErr {
if (!state.dict.has(key)) {
return { err: `"${key}" not found.` };
}
return state.dict.get(key)!;
}

function set(state: State, key: string, val: Val): string | undefined {
state.dict.set(key, val);
return undefined;
}

function exe(state: State, name: string, args: Val[]): ValOrErr {
const nullVal: Val = { t: "null", v: undefined };
Expand Down Expand Up @@ -552,11 +564,16 @@ export function doTests(
}[] = [];
for (let t = 0; t < len(tests); ++t) {
const { name, code, err, out } = tests[t];
const state: State = { output: "" };
const state: State = {
dict: new Map<string, Val>(),
output: "",
};
const env: Env = { funcs: {}, vars: {}, mocks: {} };
const startTime = getTimeMs();
const valOrErrs = invoke(
{
get: (key: string) => get(state, key),

Check failure on line 575 in src/test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Argument of type '{ get: (key: string) => ValOrErr; set: (key: string, val: Val) => string | undefined; print: (str: string, withNewLine: boolean) => void; exe: (name: string, args: Val[]) => ValOrErr; ... 5 more ...; recurBudget: number; }' is not assignable to parameter of type 'Ctx'.
set: (key: string, val: Val) => set(state, key, val),
print: (str, withNewLine) => {
state.output += str + (withNewLine ? "\n" : "");
},
Expand Down

0 comments on commit 4d2dd7c

Please sign in to comment.