This repository has been archived on 2021-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
DiscordRP/test/lib/test_set.rb
Arthur Poulet 3a69460051
All checks were successful
continuous-integration/drone/push Build is passing
test: fix set
2021-08-19 19:54:45 +02:00

33 lines
740 B
Ruby

require "pry"
require_relative "../base"
require_relative "../../src/lib/set"
class SetTest < Test::Unit::TestCase
def test_base
r = Roll::Set.parse("2d20+11d6 +6")
assert_equal "2d20 + 11d6 + 6", r.to_s
assert_equal "2d20+11d6+6", r.to_s(spaces: "")
assert_nil r.result
r.roll!
assert r.result
assert r.result.to_i
assert r.result.to_s
end
def test_plus_prefix_parsing
r = Roll::Set.parse("+2d20+11d6 -6")
assert_equal "2d20 + 11d6 - 6", r.to_s
assert_nil r.result
r.roll!
assert r.result
end
def test_less_prefix_parsing
r = Roll::Set.parse("-2d20+11d6 -6")
assert_equal "- 2d20 + 11d6 - 6", r.to_s
assert_nil r.result
r.roll!
assert r.result
end
end