Skip to content

Commit ab7f15a

Browse files
committed
assert corrections
1 parent 52999f0 commit ab7f15a

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspython-cli",
3-
"version": "2.1.14",
3+
"version": "2.1.15",
44
"description": "CLI for jspython. Allows you to run jspython (*.jspy) files",
55
"main": "./lib/public-api.js",
66
"bin": {

src/assert.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
export class Assert {
32
#chainedCheckCount: number = 1;
43
public status: boolean = true;
@@ -45,6 +44,26 @@ export class Assert {
4544
);
4645
}
4746

47+
isTruthy(value: unknown): Assert {
48+
return this.assertFunction(
49+
value,
50+
null,
51+
(e, r) => !!e,
52+
(e, r) =>
53+
`Value '${e}' is not Truthy - https://developer.mozilla.org/en-US/docs/Glossary/Truthy`
54+
);
55+
}
56+
57+
isFalsy(value: unknown): Assert {
58+
return this.assertFunction(
59+
value,
60+
null,
61+
(e, r) => !e,
62+
(e, r) =>
63+
`Value '${e}' is not Falsy - https://developer.mozilla.org/en-US/docs/Glossary/Falsy`
64+
);
65+
}
66+
4867
isTrue(value: unknown): Assert {
4968
return this.assertFunction(
5069
value,

src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ async function main() {
9090
console.log(` :\> jspython -f (fileName.jspy)`);
9191
console.log(` :\> jspython --file=(fileName.jspy)`);
9292
console.log(` :\> jspython --file=(fileName.jspy) --srcRoot=src`);
93+
console.log(` :\> jspython --file=(fileName.jspy) --param1=someValue1 --param2=someValue2`);
9394
console.log(' ');
9495
return;
9596
}

src/jspython-node.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ async function initialize(baseSource: string) {
101101
}
102102

103103
initialScope.assert = (name: string, dataContext: any) => assert(name, dataContext);
104-
initialScope.showAsserts = () => console.table(initialScope.asserts);
104+
initialScope.showAsserts = () =>
105+
console.table(
106+
initialScope.asserts?.map((r: any) => ({
107+
status: r.success ? 'success' : 'fail',
108+
assert: `${r.name}${!!r.description ? ': ' : ''}${r.description || ''}`.trim()
109+
}))
110+
);
105111
initialScope.print = (...args: any) =>
106112
logFn({
107113
time: new Date(),

0 commit comments

Comments
 (0)