Basically, just specify that the language is ecmascript, then write the tests as you usually do, but using ecmascript instead.
However, please note that the code has to be at least close to syntactically correct C++-code, the reason is that a C++-parser is used to parse the testsuite. Specifically, '{', '<', '[' and '(' have to be balanced, and strings have to be valid C++-strings.
You can still test things like inline regexps by using ecmascript code in strings in your ecmascript tests, e.g. eval("...")
group "tutorial_e1";
language ecmascript;
// All tests are ecmascript, unless we specify otherwise.
test("Basic ecmascript, ensuring that 1 is 1.")
{
verify( 1 == 1 );
}
html {
//! <html><head><title>Simple ecmascript test</title></head>
//! <body>
//! <form name=foo>
//! <input name=bar type=submit value="Don't press me!">
//! </form>
//! </body>
//! </html>
}
test("Looking for forms in a just specified HTML document")
{
verify( document.foo.bar.value == "Don't press me!" );
}
test("Asynchronous ecmascript test")
async;
{
// Call ST_passed in 10ms.
setTimeout( ST_passed, 10 );
}
Expected output
========================================================================= /home/ph/src/opera-oom2/modules/selftest/documentation/tutorial/tutoriale1.ot(1): tutorial_e1 ========================================================================= Basic ecmascript, ensuring that 1 is 1. ....................... Passed Looking for forms in a just specified HTML document ........... Passed Asynchronous ecmascript test .................................. Passed =========================================================================