Debian Codegraph @

esniff/test/utils/ensure-string-literal.js

raw
1 "use strict";
2
3 module.exports = function (t, a) {
4 var str;
5 a.throws(function () { t(); }, TypeError, "Undefined");
6 a.throws(function () { t(null); }, TypeError, "Null");
7 a.throws(function () { t({}); }, TypeError, "Object");
8 a.throws(function () { t(""); }, TypeError, "Empty code");
9 a(t("\"\""), "\"\"", "Empty \" string");
10 a(t("''"), "''", "Empty ' string");
11 a.throws(function () { t("\"sdfsdf"); }, TypeError, "Not finished \" string");
12 a.throws(function () { t("'sdfsdf"); }, TypeError, "Not finished ' string");
13 str = "'sdf\\'fefeefe\\\\efefe\\n\\\\\\'\\'efef\"\" \"sdfdfsdf'";
14 a(t(str), str, "' string");
15 str = "\"sdf\\\"fefeefe\\\\efefe\\n\\\\\\\"\\\"efef'' 'sdfdfsdf\"";
16 a(t(str), str, "Messy \" string");
17 a.throws(
18 function () { t(" \"sdf\\\"fefeefe\\\\efefe\\n\\\\\\\"\\\"efef'' 'sdfdfsdf\""); },
19 TypeError, "Starts with ws"
20 );
21 a.throws(
22 function () { t("\"sdf\\\"fefeefe\\\\efefe\\n\\\\\\\"\\\"efef'' 'sdfdfsdf\" "); },
23 TypeError, "Ends with ws"
24 );
25 a.throws(function () { t("34"); }, TypeError, "Number");
26 };