[webkit-dev] new style for JavaScript layout tests
Maciej Stachowiak
mjs at apple.com
Sun Jan 8 21:43:07 PST 2006
Hi everyone,
I've redone most of our JavaScript layout tests (in LayoutTests/fast/
js to use a new style based on how the KDE JS tests work.
I'd like to ask that all new JavaScript layout tests be done with
this new style.
To make a new-style JS tests, you make a new .js file in LayoutTests/
fast/js/resources using shouldBe() assertions. Then run the new make-
js-test-wrappers script in WebKitTools/Scripts, and a new .html file
that loads your script will be generated in LayoutTests/fast/js
Here's an example of a test JavaScript file, has-own-propery.js:
description(
"This test verifies the behaviour of Object.prototype.hasOwnProperty,
as documented in ECMA-262 rev3 section 15.2.4.5."
);
shouldBe("typeof {foo : 'yum'}.hasOwnProperty", '"function"');
shouldBeTrue("({foo : 'yum'}).hasOwnProperty('foo')");
shouldBeTrue("''.hasOwnProperty('length')");
shouldBeFalse("({foo : 'yum'}).hasOwnProperty('bar')");
shouldBeFalse("({foo : 'yum'}).hasOwnProperty('toString')");
shouldBeFalse("''.hasOwnProperty('toString')");
var successfullyParsed = true;
When you load has-own-property.html in a web browser, the results
look like this:
This test verifies the behaviour of Object.prototype.hasOwnProperty,
as documented in ECMA-262 rev3 section 15.2.4.5.
On success, you will see a series of "PASS" messages, followed by
"TEST COMPLETE".
PASS typeof {foo : 'yum'}.hasOwnProperty is "function"
PASS ({foo : 'yum'}).hasOwnProperty('foo') is true
PASS ''.hasOwnProperty('length') is true
PASS ({foo : 'yum'}).hasOwnProperty('bar') is false
PASS ({foo : 'yum'}).hasOwnProperty('toString') is false
PASS ''.hasOwnProperty('toString') is false
PASS successfullyParsed is true
TEST COMPLETE
In addition to shouldBe, shouldBeTrue and shouldBeFalse, there are
also shouldBeUndefined, shouldBeNaN and shouldThrow assertions.
Regards,
Maciej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/webkit-dev/attachments/20060108/2f8b34e5/attachment.html
More information about the webkit-dev
mailing list