summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua/test.lua
blob: 22a4005d20cf6b1b947ff0f7ba34a1b6d8b1f76f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- Support code used primarily for tests. This is loaded only when running
-- tests, not during normal Crawl execution.

util.namespace('test')

test.FAILMAP = 'level-fail.map'

function test.map_assert(condition, message)
  if not condition then
    debug.dump_map(test.FAILMAP)
    assert(false, message .. " (map dumped to " .. test.FAILMAP .. ")")
  end
  return condition
end

function test.regenerate_level(place)
  if place then
    debug.goto_place(place)
  end
  debug.flush_map_memory()
  dgn.reset_level()
  debug.generate_level()
end

function test.level_contains_item(item)
  for y = 1, dgn.GYM - 2 do
    for x = 1, dgn.GXM - 2 do
      if iter.stack_search(x, y, item) then
        return true
      end
    end
  end
  return false
end