Espruino/tests/test_tostring.js
Michael Duerinckx 7f5308590b Rename numbered tests to something more descriptive - closes #16
test077 is the only one I really couldn't figure out what it was meant
to test.
2014-03-01 22:15:28 +00:00

23 lines
497 B
JavaScript

// Test for toString
function Foo() {}
Foo.prototype.toString = function() { return "Hello World"; }
var a = [
[1,2,3,4], "1,2,3,4",
"1234", "1234",
1234, "1234",
1234.0, "1234", // strange, but true
1234.56, "1234.56",
{a:2}, "[object Object]",
new Foo(), "Hello World",
function (b) {c}, "function (b) {c}"
];
var result = 1;
for (var i=0;i<a.length;i+=2) {
a[i] = a[i].toString();
if (a[i]!=a[i+1]) result = 0;
}