var noParamFuns = ["".bold, "".italics, "".fixed, "".strike, "".small, "".big, "".blink, "".sup, "".sub]; var noParamTags = ["b", "i", "tt", "strike", "small", "big", "blink", "sup", "sub"]; function testNoParam(s) { for (var i=0; i" + String(s) + ""); } } testNoParam("Foo"); testNoParam('aaa"bbb\'c<>123'); testNoParam(123); // toString should be called, not valueOf testNoParam({toString: () => 1, valueOf: () => { throw "fail"; } }); assertEq("".anchor.length, 1); assertEq("".link.length, 1); assertEq("".fontsize.length, 1); assertEq("".fontcolor.length, 1); // " in the attribute value is escaped (") assertEq("bla\"<>'".anchor("foo'<>\"\"123\"/\\"), """123"/\\\">bla\"<>'"); assertEq("bla\"<>'".link("foo'<>\"\"123\"/\\"), """123"/\\\">bla\"<>'"); assertEq("bla\"<>'".fontsize("foo'<>\"\"123\"/\\"), """123"/\\\">bla\"<>'"); assertEq("bla\"<>'".fontcolor("foo'<>\"\"123\"/\\"), """123"/\\\">bla\"<>'"); assertEq("".anchor('"'), ''); assertEq("".link('"'), ''); assertEq("".fontcolor('"'), ''); assertEq("".fontsize('"'), ''); assertEq("".anchor('"1'), ''); assertEq("".link('"1'), ''); assertEq("".fontcolor('"1'), ''); assertEq("".fontsize('"1'), ''); assertEq("".anchor('"""a"'), ''); assertEq("".link('"""a"'), ''); assertEq("".fontcolor('"""a"'), ''); assertEq("".fontsize('"""a"'), ''); assertEq("".anchor(""), ''); assertEq("".link(""), ''); assertEq("".fontcolor(""), ''); assertEq("".fontsize(""), ''); assertEq("foo".anchor(), "foo"); assertEq("foo".link(), "foo"); assertEq("foo".fontcolor(), "foo"); assertEq("foo".fontsize(), "foo"); assertEq("foo".anchor(3.14), 'foo'); assertEq("foo".link(3.14), 'foo'); assertEq("foo".fontcolor(3.14), 'foo'); assertEq("foo".fontsize(3.14), 'foo'); assertEq("foo".anchor({}), 'foo'); assertEq("foo".link(Math), 'foo'); assertEq("foo".fontcolor([1,2]), 'foo'); assertEq("foo".fontsize({}), 'foo'); // toString should be called, not valueOf, and toString must be called on |this| // before it's called on the argument. Also makes sure toString is called only // once. var count = 0; var o1 = {toString: () => { return count += 1; }, valueOf: () => { throw "fail"; } }; var o2 = {toString: () => { return count += 5; }, valueOf: () => { throw "fail"; } }; assertEq("".anchor.call(o1, o2), '1'); assertEq("".link.call(o1, o2), '7'); assertEq("".fontcolor.call(o1, o2), '13'); assertEq("".fontsize.call(o1, o2), '19'); assertEq(count, 24);