-
-
Save qunabu/b1daa6550c381d7a4a4ebfa48e6b63d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("The RPN expression evaluator", () => { | |
it("should return null when the expression is an empty string", () => { | |
const result = RPN(""); | |
expect(result).toBeNull(); | |
}); | |
it("should return the same value when the expression holds a single value", () => { | |
const result = RPN("42"); | |
expect(result).toBe(42); | |
}); | |
it("should properly calculate an expression", () => { | |
const result = RPN("5 1 2 + 4 * - 10 /"); | |
expect(result).toBe(-0.7); | |
}); | |
it("should throw an error whenever an invalid expression is passed", () => { | |
const compute = () => RPN("1 + - 1"); | |
expect(compute).toThrow(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment