aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-11-02 12:50:54 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-11-02 12:50:54 +0300
commit3a280cc4577dab4240d5feadda2f532aaa5dabe0 (patch)
treec47c3509a33a27946c03a107850ea9666c874338 /spec
parent5935a1d39658fc0f2dd1ab04f1a3f3dd5413fbb8 (diff)
downloadluarocks-3a280cc4577dab4240d5feadda2f532aaa5dabe0.tar.gz
luarocks-3a280cc4577dab4240d5feadda2f532aaa5dabe0.tar.bz2
luarocks-3a280cc4577dab4240d5feadda2f532aaa5dabe0.zip
Add a few tests for luarocks.persist
One fails.
Diffstat (limited to 'spec')
-rw-r--r--spec/persist.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/persist.lua b/spec/persist.lua
new file mode 100644
index 00000000..6b69dab4
--- /dev/null
+++ b/spec/persist.lua
@@ -0,0 +1,55 @@
1local test_env = require("test/test_environment")
2
3test_env.unload_luarocks()
4local persist = require("luarocks.persist")
5
6describe("Luarocks persist test #whitebox #w_persist", function()
7 describe("persist.save_from_table_to_string", function()
8 it("simple table", function()
9 assert.are.same([[
10bar = 1234
11foo = "string"
12]], persist.save_from_table_to_string({foo = "string", bar = 1234}))
13 end)
14
15 it("nested tables", function()
16 assert.are.same([[
17bar = {
18 baz = "string"
19}
20foo = {
21 1, 2, 3, 4
22}
23]], persist.save_from_table_to_string({foo = {1, 2, 3, 4}, bar = {baz = "string"}}))
24 end)
25
26 it("strings with quotes", function()
27 assert.are.same([[
28bar = "a \\backslash?"
29foo = "a \"quote\"?"
30]], persist.save_from_table_to_string({foo = 'a "quote"?', bar = 'a \\backslash?'}))
31 end)
32
33 it("multiline strings", function()
34 assert.are.same([===[
35bar = [==[
36]]
37]=]]==]
38foo = [[
39First line
40Second line]]
41]===], persist.save_from_table_to_string({foo = "First line\nSecond line", bar = "]]\n]=]"}))
42 end)
43
44 it("multiline strings ending with brackets", function()
45 assert.are.same([===[
46bar = [==[
47]]
48]=]==]
49foo = [=[
50First line
51Second line [1]]=]
52]===], persist.save_from_table_to_string({foo = "First line\nSecond line [1]", bar = "]]\n]="}))
53 end)
54 end)
55end)