aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-22 23:10:13 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-10-21 13:30:51 -0300
commit048edb8e011ce2e7e6910e305dc9a3242d319831 (patch)
tree76aacbd0915a80fb0bc4dacf20a40a889993343f
parent7ed4465b8177dcaa8742f079bc6b4d2745fd68c8 (diff)
downloadluarocks-048edb8e011ce2e7e6910e305dc9a3242d319831.tar.gz
luarocks-048edb8e011ce2e7e6910e305dc9a3242d319831.tar.bz2
luarocks-048edb8e011ce2e7e6910e305dc9a3242d319831.zip
tests: unit test updates
-rw-r--r--spec/unit/fetch_spec.lua2
-rw-r--r--spec/unit/fun_spec.lua11
-rw-r--r--spec/unit/rockspecs_spec.lua14
-rw-r--r--spec/unit/util_spec.lua2
4 files changed, 10 insertions, 19 deletions
diff --git a/spec/unit/fetch_spec.lua b/spec/unit/fetch_spec.lua
index bea50d78..85d89b6c 100644
--- a/spec/unit/fetch_spec.lua
+++ b/spec/unit/fetch_spec.lua
@@ -55,7 +55,7 @@ describe("luarocks fetch #unit", function()
55 fdr:close() 55 fdr:close()
56 fdw:close() 56 fdw:close()
57 57
58 return true, destfile 58 return destfile
59 end 59 end
60 60
61 runner = require("luacov.runner") 61 runner = require("luacov.runner")
diff --git a/spec/unit/fun_spec.lua b/spec/unit/fun_spec.lua
index bffb60d7..774aa937 100644
--- a/spec/unit/fun_spec.lua
+++ b/spec/unit/fun_spec.lua
@@ -58,17 +58,6 @@ describe("luarocks.fun #unit", function()
58 end) 58 end)
59 end) 59 end)
60 60
61 describe("fun.traverse", function()
62 it("recursively applies a function to each element in a given table and returns the results in a new table", function()
63 local t
64
65 t = {1, 2, {3, 4, {5, 6}}}
66 assert.same(fun.traverse(t, addOne), {2, 3, {4, 5, {6, 7}}})
67 t = {1, 2, {}, {1, {}, 2}}
68 assert.same(fun.traverse(t, addOne), {2, 3, {}, {2, {}, 3}})
69 end)
70 end)
71
72 describe("fun.filter", function() 61 describe("fun.filter", function()
73 it("filters the elements in the given table and returns the result in a new table", function() 62 it("filters the elements in the given table and returns the result in a new table", function()
74 local t 63 local t
diff --git a/spec/unit/rockspecs_spec.lua b/spec/unit/rockspecs_spec.lua
index 7eb033c8..2357a2a1 100644
--- a/spec/unit/rockspecs_spec.lua
+++ b/spec/unit/rockspecs_spec.lua
@@ -28,7 +28,9 @@ describe("luarocks.rockspecs #unit", function()
28 28
29 assert(rockspec == out) 29 assert(rockspec == out)
30 assert.same(rockspec.build_dependencies, { 30 assert.same(rockspec.build_dependencies, {
31 { name = "luarocks-build-foo", constraints = {} }, 31 queries = {
32 { name = "luarocks-build-foo", constraints = {} }
33 },
32 }) 34 })
33 end) 35 end)
34 36
@@ -53,9 +55,9 @@ describe("luarocks.rockspecs #unit", function()
53 55
54 assert(rockspec == out) 56 assert(rockspec == out)
55 57
56 assert.same(rockspec.build_dependencies, { 58 assert.same(rockspec.build_dependencies, { "luarocks-build-cpp >= 1.0", queries = {
57 { name = "luarocks-build-cpp", constraints = { { op = ">=", version = { string = "1.0", 1, 0 } } } }, 59 { name = "luarocks-build-cpp", constraints = { { op = ">=", version = { string = "1.0", 1, 0 } } } },
58 }) 60 }})
59 end) 61 end)
60 62
61 it("does not add a build dependency for 'none' build type", function() 63 it("does not add a build dependency for 'none' build type", function()
@@ -75,7 +77,7 @@ describe("luarocks.rockspecs #unit", function()
75 local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick) 77 local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick)
76 78
77 assert(rockspec == out) 79 assert(rockspec == out)
78 assert.same(rockspec.build_dependencies, {}) 80 assert.same(rockspec.build_dependencies, { queries = {}})
79 end) 81 end)
80 82
81 it("does not add a build dependency for 'module' build type", function() 83 it("does not add a build dependency for 'module' build type", function()
@@ -95,7 +97,7 @@ describe("luarocks.rockspecs #unit", function()
95 local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick) 97 local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick)
96 98
97 assert(rockspec == out) 99 assert(rockspec == out)
98 assert.same(rockspec.build_dependencies, {}) 100 assert.same(rockspec.build_dependencies, { queries = {}})
99 end) 101 end)
100 102
101 for d in lfs.dir(test_env.testing_paths.src_dir .. "/luarocks/build") do 103 for d in lfs.dir(test_env.testing_paths.src_dir .. "/luarocks/build") do
@@ -118,7 +120,7 @@ describe("luarocks.rockspecs #unit", function()
118 local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick) 120 local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick)
119 121
120 assert(rockspec == out) 122 assert(rockspec == out)
121 assert.same(rockspec.build_dependencies, {}) 123 assert.same(rockspec.build_dependencies, { queries = {}})
122 end) 124 end)
123 end 125 end
124 end 126 end
diff --git a/spec/unit/util_spec.lua b/spec/unit/util_spec.lua
index 8b234b2e..5b19bb34 100644
--- a/spec/unit/util_spec.lua
+++ b/spec/unit/util_spec.lua
@@ -83,8 +83,8 @@ describe("luarocks.util #unit", function()
83 assert.are.same({}, collect(util.sortedpairs({}, {"k1", "k2"}))) 83 assert.are.same({}, collect(util.sortedpairs({}, {"k1", "k2"})))
84 assert.are.same({ 84 assert.are.same({
85 {"k3", "v3"}, 85 {"k3", "v3"},
86 {"k2", "v2", {"sub order"}},
87 {"k1", "v1"}, 86 {"k1", "v1"},
87 {"k2", "v2"},
88 {"k4", "v4"}, 88 {"k4", "v4"},
89 {"k5", "v5"}, 89 {"k5", "v5"},
90 }, collect(util.sortedpairs({ 90 }, collect(util.sortedpairs({