Skip to content

Commit

Permalink
Added testing for pylib (#1624)
Browse files Browse the repository at this point in the history
* Added testing for pylib

* run yarn format

* Fixed broken test case for pylib

* Updated pylib test snapshot

* Use strict equality operator in pylib

---------

Co-authored-by: sayomaki <[email protected]>
Co-authored-by: Richard Dominick <[email protected]>
Co-authored-by: Martin Henz <[email protected]>
  • Loading branch information
4 people authored Apr 1, 2024
1 parent e1637fe commit 8aa08d5
Show file tree
Hide file tree
Showing 3 changed files with 687 additions and 11 deletions.
339 changes: 339 additions & 0 deletions src/stdlib/__tests__/__snapshots__/pylib.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adding an integer and a float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_adder(1.0, BigInt(2))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 3,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`adding two floats is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_adder(1.0, 2.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 3,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`adding two integers is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_adder(BigInt(1), BigInt(2))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 3n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`cannot divide non-number values: expectParsedError 1`] = `
Object {
"alertResult": Array [],
"code": "__py_divider(\\"a\\", 2)",
"displayResult": Array [],
"numErrors": 1,
"parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.",
"result": undefined,
"resultStatus": "error",
"visualiseListResult": Array [],
}
`;

exports[`cannot floor non-number values: expectParsedError 1`] = `
Object {
"alertResult": Array [],
"code": "__py_floorer(\\"a\\", 2)",
"displayResult": Array [],
"numErrors": 1,
"parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.",
"result": undefined,
"resultStatus": "error",
"visualiseListResult": Array [],
}
`;

exports[`cannot mod non-number values: expectParsedError 1`] = `
Object {
"alertResult": Array [],
"code": "__py_modder(\\"a\\", 2)",
"displayResult": Array [],
"numErrors": 1,
"parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.",
"result": undefined,
"resultStatus": "error",
"visualiseListResult": Array [],
}
`;

exports[`cannot multiply non-number values: expectParsedError 1`] = `
Object {
"alertResult": Array [],
"code": "__py_multiplier(\\"a\\", 2)",
"displayResult": Array [],
"numErrors": 1,
"parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.",
"result": undefined,
"resultStatus": "error",
"visualiseListResult": Array [],
}
`;

exports[`cannot power non-number values: expectParsedError 1`] = `
Object {
"alertResult": Array [],
"code": "__py_powerer(\\"a\\", 2)",
"displayResult": Array [],
"numErrors": 1,
"parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.",
"result": undefined,
"resultStatus": "error",
"visualiseListResult": Array [],
}
`;

exports[`dividing float and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_divider(1.0, 2.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 0.5,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`dividing integer and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_divider(BigInt(2), 1.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`dividing integer and integer is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_divider(BigInt(1), BigInt(2))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 0.5,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`flooring float and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_floorer(1.0, 2.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 0n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`flooring integer and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_floorer(BigInt(2), 1.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`flooring integer and integer is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_floorer(BigInt(2), BigInt(1))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`minusing an integer from a float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_minuser(1.0, BigInt(2))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": -1,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`minusing two floats is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_minuser(1.0, 2.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": -1,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`minusing two integers is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_minuser(BigInt(1), BigInt(2))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": -1n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`modding float and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_modder(1.0, 2.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 1,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`modding integer and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_modder(BigInt(2), 1.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 0,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`modding integer and integer is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_modder(BigInt(2), BigInt(1))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 0n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`multiplying float and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_multiplier(1.0, 2.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`multiplying integer and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_multiplier(1.0, BigInt(2))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`multiplying integer and integer is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_multiplier(BigInt(1), BigInt(2))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`powering float and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_powerer(1.0, 2.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 1,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`powering integer and float is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_powerer(BigInt(2), 1.0)",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`powering integer and integer is ok: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "__py_powerer(BigInt(2), BigInt(1))",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 2n,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;
Loading

0 comments on commit 8aa08d5

Please sign in to comment.