mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
858 B
57 lines
858 B
12 years ago
|
|
||
|
/*===
|
||
|
FOOBAR
|
||
|
===*/
|
||
|
|
||
|
try {
|
||
|
print('fOoBaR'.toLocaleUpperCase());
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|
||
|
|
||
|
/*===
|
||
|
TypeError
|
||
|
TypeError
|
||
|
string 4 TRUE
|
||
|
string 5 FALSE
|
||
|
string 3 123
|
||
|
string 6 FOOBAR
|
||
|
string 9 1,FOO,BAR
|
||
|
string 15 [OBJECT OBJECT]
|
||
|
===*/
|
||
|
|
||
|
function coercionTest() {
|
||
|
function test(str) {
|
||
|
var t;
|
||
|
|
||
|
try {
|
||
|
t = String.prototype.toLocaleUpperCase.call(str);
|
||
|
print(typeof t, t.length, t);
|
||
|
} catch (e) {
|
||
|
print(e.name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
test(undefined);
|
||
|
test(null);
|
||
|
test(true);
|
||
|
test(false);
|
||
|
test(123.0);
|
||
|
test('FoObAr');
|
||
|
test([1,'fOO','Bar']);
|
||
|
test({ foo: 1, bar: 2 });
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
coercionTest();
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|
||
|
|
||
|
/* FIXME: basic tests like coercion etc. */
|
||
|
|
||
|
/* FIXME: test that locale specific conversions actually work.
|
||
|
* How to force locale for a test?
|
||
|
*/
|
||
|
|