Commit graph

27 commits

Author SHA1 Message Date
davidot
0d8bab82f0 LibJS: Add custom details to toBe{True, False} shown on failure
Any test with multiple expect(...).toBe{True, False} checks is very hard
to debug.
2023-01-23 09:56:50 +00:00
davidot
fa030d7b9c LibJS: Clarify more errors in test-common
Without a message these just show 'ExpectationError' even if the check
has multiple steps.
2023-01-23 09:56:50 +00:00
davidot
cf0d30add6 LibJS: Add a function to ensure calls are made within the same second
Before these tests could be flaky if they happened to be called around
the edge of a second. Now we try up to 5 times to execute the tests
while staying within the same second.
2022-12-03 23:04:08 +00:00
davidot
49fc0e2514 LibJS: Add space in output of toEval in test-common.js 2022-11-17 16:05:20 +00:00
davidot
80f23abd0a LibJS: Add descriptive output to test-commons expect().toThrow()
This (and still some other methods) just say Expectation error leaving
the user completely in the dark whether the method threw at all.
And since we have nice function printing now we can just toString the
function since most are lambda's.
2022-10-23 15:48:45 +02:00
Ali Mohammad Pur
a5958b5f45 LibJS: Allow 'expect().fail("some random string")' in test-js
Previously fail() wanted the fail object to be a callable, allow it to
be a string also.
2022-03-20 10:44:32 +03:30
Ali Mohammad Pur
8b50009e9b LibTest: Provide detailed per-file JSON output with --per-file
This makes test-js style runners dump out output in the same format as
libjs-test262's per-file output.
2022-03-16 15:44:52 +00:00
Ali Mohammad Pur
0fe97cdfe4 LibJS: Print the expected and received value on expect.toEqual() failure
'ExpectationError' is hardly an actionable error message.
2022-02-23 03:17:12 +03:30
Anonymous
1e0facb7ee LibJS: Implement the Number::remainder AO using fmod
The ECMA verbiage for modulus is the mathematical definition implemented
by fmod, so let's just use that rather than trying to reimplement all
the edge cases.
2022-02-16 11:18:41 +00:00
davidot
45646eee43 LibJS: Fix Map Iterators when elements are deleted during iteration
Before this would assume that the element found in operator++ was still
valid when dereferencing it in operator*.
Since any code can have been run since that increment this is not always
valid.
To further simplify the logic of the iterator we no longer store the
index in an optional.
2022-02-10 14:09:39 +00:00
davidot
450dedabd1 LibJS: Add messages to the toEval and toEvalTo tests
This makes it a lot easier to understand what is going wrong when an
eval test fails. As an example instead of just getting:
`ExpectationError`
You would now get:
`ExpectationError: Expected _1_2E+0_1_ to eval to _12_ but got _120_`.
2021-11-30 17:05:32 +00:00
Hendi
c194afd17c LibJS: Fix runaway let scope when parsing for-in/of statements
This requires variables that should be exported to the script host
or to other scripts to be declared as var (such as in test-common.js),
since lexically-scoped variables won't be visible.
2021-07-06 00:15:37 +01:00
Linus Groh
5ee753ffaa LibJS/Tests: Fix toBeFalse() details prefix
Copy/paste error from toBeTrue().
2021-06-28 19:16:06 +01:00
Linus Groh
63a1275378 LibJS/Tests: Improve valueToString() output
This regressed recently and would only output a bunch of '[object Foo]',
the reason being that String(value) failed in some cases - which is
easily fixed by trying that first and using Object.prototype.toString()
as a fallback in the case of an exception :^)
2021-06-27 22:17:05 +01:00
Linus Groh
299c3069c1 LibJS/Tests: Use eval() for toEvalTo(), not Function()
Since we have had eval() for a while now, we can finally use it here -
this allows us to get rid of the confusing return statements in tested
source code.
2021-06-18 20:35:23 +01:00
Linus Groh
7489189645 LibJS/Tests: Use Object.prototype.toString() for values in test details
Using String() like we did before depends on objects having either
toString, valueOf, or  @@toPrimitive, which is not the case for objects
with no prototype.
2021-06-16 22:49:04 +01:00
Idan Horowitz
670be04c81 LibJS: Add the Set built-in object 2021-06-09 11:48:04 +01:00
Ali Mohammad Pur
09cf1040ef LibJS/Tests: Catch exceptions in describe() itself
Otherwise exceptions thrown in that state would simply terminate the
test.
2021-06-04 16:07:42 +04:30
Linus Groh
b221cad659 LibJS/Tests: Add details for toBeTrue() / toBeFalse() expectation error 2021-05-13 23:59:00 +01:00
Linus Groh
f28491dbe7 LibJS/Tests: Add details for toThrowWithMessage did-not-throw case 2021-05-13 23:59:00 +01:00
Linus Groh
5b18bce23c LibJS/Tests: Add prefix to toThrowWithMessage expectation error details
This way we get some more information about where things went wrong.
2021-05-13 23:59:00 +01:00
Linus Groh
431782bcd6 LibJS/Tests: Add details for toThrowWithMessage() expectation error 2021-05-11 22:41:35 +01:00
Linus Groh
346560d7c8 LibJS/Tests: Use hasOwnProperty() for duplicate test check
The current way of doing this would also traverse the prototype chain,
and therefore yield false positive results for keys like "toString".
2021-05-05 15:58:53 +01:00
Linus Groh
883e8683b2 LibJS/Tests: Remove fileName and lineNumber args from ExpectationError
This is nono-standard, not supported by our Error implementation and not
even used anywhere, so let's just remove it.
2021-04-23 20:30:52 +02:00
Linus Groh
d400be05ec LibJS/Tests: Improve expectation error details 2021-04-23 20:30:52 +02:00
Linus Groh
1ea8d73628 LibJS: Provide 'details' key in results object for duplicate test
The test-js program expects this to exist for 'result: "fail"' results
and would crash if any duplicated test(message) occurs, as we didn't
provide 'details' in that case.
2021-03-31 23:59:21 +02:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Renamed from Libraries/LibJS/Tests/test-common.js (Browse further)