Prefix clusterio/lib imports with lib

Use lib* prefix for the modules impored from the lib package to help
distinguish them more from ordinary variables.  Fix up the naming
convention for files to be consistently lowercase_underscore for
JavaScript files.
This commit is contained in:
Hornwitser committed 2020-10-23 21:22:43 +02:00
1 parent fbbaf3dd3a
commit 24397b75cc
55 files changed
+692 -668

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
"use strict";
const assert = require("assert").strict;
const libLuaTools = require("@clusterio/lib/lua_tools");
describe("lib/lua_tools", function() {
describe("escapeString()", function() {
it("should escape backslashes", function() {
assert.equal(libLuaTools.escapeString("\\a"), "\\\\a");
});
it("should escape double quotes", function() {
assert.equal(libLuaTools.escapeString('"a"'), '\\"a\\"');
});
it("should escape single quotes", function() {
assert.equal(libLuaTools.escapeString("'a'"), "\\'a\\'");
});
it("should escape nul bytes", function() {
assert.equal(libLuaTools.escapeString("a\0b"), "a\\0b");
});
it("should escape newlines", function() {
assert.equal(libLuaTools.escapeString("a\nb"), "a\\nb");
});
it("should escape carriage return", function() {
assert.equal(libLuaTools.escapeString("a\rb"), "a\\rb");
});
it("should escape all combined", function() {
assert.equal(libLuaTools.escapeString("a\\b\"c'd\0e\nf\rg"), "a\\\\b\\\"c\\'d\\0e\\nf\\rg");
});
});
});