2020-07-05 10:47:40 -07:00
|
|
|
const message = "oops, Value::to_number() failed";
|
2020-05-18 00:28:00 +01:00
|
|
|
|
2020-07-05 10:47:40 -07:00
|
|
|
const o = {
|
2020-07-06 07:37:45 -07:00
|
|
|
toString() {
|
|
|
|
|
throw new Error(message);
|
|
|
|
|
},
|
2020-07-05 10:47:40 -07:00
|
|
|
};
|
2020-05-18 00:28:00 +01:00
|
|
|
|
2020-07-05 10:47:40 -07:00
|
|
|
test("basic functionality", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(() => {
|
|
|
|
|
+o;
|
|
|
|
|
}).toThrowWithMessage(Error, message);
|
2020-05-18 00:28:00 +01:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(() => {
|
|
|
|
|
o - 1;
|
|
|
|
|
}).toThrowWithMessage(Error, message);
|
2020-05-18 00:28:00 +01:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(() => {
|
|
|
|
|
"foo".charAt(o);
|
|
|
|
|
}).toThrowWithMessage(Error, message);
|
2020-05-18 00:28:00 +01:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(() => {
|
|
|
|
|
"bar".repeat(o);
|
|
|
|
|
}).toThrowWithMessage(Error, message);
|
2020-07-05 10:47:40 -07:00
|
|
|
});
|