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.
49 lines
809 B
49 lines
809 B
/*
|
|
* Eval order of relational operators should always be the same (eval left
|
|
* first), but it's easy to break due to internal trivia.
|
|
*/
|
|
|
|
/*===
|
|
<
|
|
valueOf obj1
|
|
valueOf obj2
|
|
true
|
|
>
|
|
valueOf obj1
|
|
valueOf obj2
|
|
true
|
|
<=
|
|
valueOf obj1
|
|
valueOf obj2
|
|
true
|
|
>=
|
|
valueOf obj1
|
|
valueOf obj2
|
|
true
|
|
===*/
|
|
|
|
function getObject(name, value) {
|
|
return {
|
|
valueOf: function() {
|
|
print('valueOf', name);
|
|
return value;
|
|
}
|
|
}
|
|
}
|
|
|
|
function test() {
|
|
print('<');
|
|
print(getObject('obj1', 1) < getObject('obj2', 2));
|
|
print('>');
|
|
print(getObject('obj1', 2) > getObject('obj2', 1));
|
|
print('<=');
|
|
print(getObject('obj1', 1) <= getObject('obj2', 2));
|
|
print('>=');
|
|
print(getObject('obj1', 2) >= getObject('obj2', 1));
|
|
}
|
|
|
|
try {
|
|
test();
|
|
} catch (e) {
|
|
print(e);
|
|
}
|
|
|