dummy_spec.lua 978 B

1234567891011121314151617181920212223242526272829303132333435
  1. package.path = '../../?.lua;' .. -- tests root
  2. '../?.lua;' .. -- mod root
  3. package.path
  4. require("crafting/tests/dummy")
  5. describe("ItemStack", function()
  6. it("parses simple", function()
  7. local stack = ItemStack("default:stone")
  8. assert.equals("default:stone", stack:get_name())
  9. assert.equals(1, stack:get_count())
  10. end)
  11. it("parses dual string", function()
  12. local stack = ItemStack("default:stone 11")
  13. assert.equals("default:stone", stack:get_name())
  14. assert.equals(11, stack:get_count())
  15. end)
  16. it("copies", function()
  17. local stack1 = ItemStack("default:stone 11")
  18. local stack2 = ItemStack(stack1)
  19. assert.not_equals(stack1, stack2)
  20. assert.is_true(stack1:get_name() == stack2:get_name())
  21. assert.is_true(stack1:get_count() == stack2:get_count())
  22. stack2:set_count(3)
  23. assert.equals(11, stack1:get_count())
  24. assert.equals(3, stack2:get_count())
  25. assert.is_true(stack1:get_count() ~= stack2:get_count())
  26. end)
  27. end)