mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Move all functions and classes currently available through lib/name and libName to be under a single flat namespace in lib. This make reorganising the lib namespace much simpler as the location of symbols can move without breaking the consumers of lib. The multi-entrypoint design was already problematic for the web plugin system which couldn't effectively use it due to how webpack's shared module system is awkward to set up with multiple entrypoints per package.
32 lines
962 B
JavaScript
32 lines
962 B
JavaScript
"use strict";
|
|
const assert = require("assert").strict;
|
|
|
|
const lib = require("@clusterio/lib");
|
|
|
|
|
|
describe("lib/lua_tools", function() {
|
|
describe("escapeString()", function() {
|
|
it("should escape backslashes", function() {
|
|
assert.equal(lib.escapeString("\\a"), "\\\\a");
|
|
});
|
|
it("should escape double quotes", function() {
|
|
assert.equal(lib.escapeString('"a"'), '\\"a\\"');
|
|
});
|
|
it("should escape single quotes", function() {
|
|
assert.equal(lib.escapeString("'a'"), "\\'a\\'");
|
|
});
|
|
it("should escape nul bytes", function() {
|
|
assert.equal(lib.escapeString("a\0b"), "a\\0b");
|
|
});
|
|
it("should escape newlines", function() {
|
|
assert.equal(lib.escapeString("a\nb"), "a\\nb");
|
|
});
|
|
it("should escape carriage return", function() {
|
|
assert.equal(lib.escapeString("a\rb"), "a\\rb");
|
|
});
|
|
it("should escape all combined", function() {
|
|
assert.equal(lib.escapeString("a\\b\"c'd\0e\nf\rg"), "a\\\\b\\\"c\\'d\\0e\\nf\\rg");
|
|
});
|
|
});
|
|
});
|