From 093894844d4d7e7e58a7a78d36f04cf59b95ff31 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 21 Mar 2025 23:12:16 +0800 Subject: improve tests --- tests/modules/graph/test.lua | 6 ++---- xmake/core/base/graph.lua | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/modules/graph/test.lua b/tests/modules/graph/test.lua index 3d5a0aede..da6218f14 100644 --- a/tests/modules/graph/test.lua +++ b/tests/modules/graph/test.lua @@ -43,14 +43,12 @@ function test_paritail_topo_sort(t) dag:partial_topo_sort_reset() local order_vertices = {} - local batch_size = math.huge - local batch, has_cycle = dag:partial_topo_sort_next(batch_size) + local batch, has_cycle = dag:partial_topo_sort_next() while #batch > 0 do for _, v in ipairs(batch) do table.insert(order_vertices, v) end - batch, has_cycle = dag:partial_topo_sort_next(batch_size) - + batch, has_cycle = dag:partial_topo_sort_next() if has_cycle then break end diff --git a/xmake/core/base/graph.lua b/xmake/core/base/graph.lua index 496bffeba..31e7038d1 100644 --- a/xmake/core/base/graph.lua +++ b/xmake/core/base/graph.lua @@ -165,6 +165,7 @@ end -- local batch4, has_cycle = g:partial_topo_sort_next(1) -- returns {} (empty, all done) -- function graph:partial_topo_sort_next(limit) + limit = limit or math.huge if not self:is_directed() then return {}, false end @@ -173,8 +174,6 @@ function graph:partial_topo_sort_next(limit) self:partial_topo_sort_reset() end - limit = limit or math.huge - -- check if we already detected a cycle if self._partial_topo_has_cycle then return {}, true -- cgit v1.3.1