diff options
| author | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-02 12:50:54 +0300 |
|---|---|---|
| committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-02 12:50:54 +0300 |
| commit | 3a280cc4577dab4240d5feadda2f532aaa5dabe0 (patch) | |
| tree | c47c3509a33a27946c03a107850ea9666c874338 | |
| parent | 5935a1d39658fc0f2dd1ab04f1a3f3dd5413fbb8 (diff) | |
| download | luarocks-3a280cc4577dab4240d5feadda2f532aaa5dabe0.tar.gz luarocks-3a280cc4577dab4240d5feadda2f532aaa5dabe0.tar.bz2 luarocks-3a280cc4577dab4240d5feadda2f532aaa5dabe0.zip | |
Add a few tests for luarocks.persist
One fails.
| -rw-r--r-- | spec/persist.lua | 55 |
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 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | |||
| 3 | test_env.unload_luarocks() | ||
| 4 | local persist = require("luarocks.persist") | ||
| 5 | |||
| 6 | describe("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([[ | ||
| 10 | bar = 1234 | ||
| 11 | foo = "string" | ||
| 12 | ]], persist.save_from_table_to_string({foo = "string", bar = 1234})) | ||
| 13 | end) | ||
| 14 | |||
| 15 | it("nested tables", function() | ||
| 16 | assert.are.same([[ | ||
| 17 | bar = { | ||
| 18 | baz = "string" | ||
| 19 | } | ||
| 20 | foo = { | ||
| 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([[ | ||
| 28 | bar = "a \\backslash?" | ||
| 29 | foo = "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([===[ | ||
| 35 | bar = [==[ | ||
| 36 | ]] | ||
| 37 | ]=]]==] | ||
| 38 | foo = [[ | ||
| 39 | First line | ||
| 40 | Second 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([===[ | ||
| 46 | bar = [==[ | ||
| 47 | ]] | ||
| 48 | ]=]==] | ||
| 49 | foo = [=[ | ||
| 50 | First line | ||
| 51 | Second line [1]]=] | ||
| 52 | ]===], persist.save_from_table_to_string({foo = "First line\nSecond line [1]", bar = "]]\n]="})) | ||
| 53 | end) | ||
| 54 | end) | ||
| 55 | end) | ||
