Skip to content

Commit

Permalink
Fixed numbers truthiness
Browse files Browse the repository at this point in the history
  • Loading branch information
OAGr committed Dec 4, 2023
1 parent 993eacd commit 3dd8044
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/squiggle-lang/__tests__/library/builtin_test.ts
Expand Up @@ -55,4 +55,11 @@ describe("Operators", () => {
testEvalToBe("typeOf(true)", '"Boolean"');
testEvalToBe("typeOf({|f| f})", '"Function"');
});
describe("not", () => {
testEvalToBe("not(3)", "false");
testEvalToBe("!!(3)", "true");
testEvalToBe("not(0)", "true");
testEvalToBe("!(0)", "true");
testEvalToBe("!(false)", "true");
});
});
2 changes: 1 addition & 1 deletion packages/squiggle-lang/src/fr/builtin.ts
Expand Up @@ -39,7 +39,7 @@ export const library = [
definitions: [
makeDefinition([frNumber], ([x]) => {
// unary prefix !
return vBool(x !== 0);
return vBool(x === 0);
}),
makeDefinition([frBool], ([x]) => {
// unary prefix !
Expand Down

0 comments on commit 3dd8044

Please sign in to comment.