test/factbase/terms/test_strings.rb in factbase-0.0.60 vs test/factbase/terms/test_strings.rb in factbase-0.1.0
- old
+ new
@@ -26,10 +26,17 @@
# Strings test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
# License:: MIT
class TestStrings < Minitest::Test
+ def test_regexp_matching
+ t = Factbase::Term.new(:matches, [:foo, '[a-z]+'])
+ assert(t.evaluate(fact('foo' => 'hello'), []))
+ assert(t.evaluate(fact('foo' => 'hello 42'), []))
+ assert(!t.evaluate(fact('foo' => 42), []))
+ end
+
def test_concat
t = Factbase::Term.new(:concat, [42, 'hi', 3.14, :hey, Time.now])
s = t.evaluate(fact, [])
assert(s.start_with?('42hi3.14'), s)
end
@@ -38,10 +45,10 @@
t = Factbase::Term.new(:concat, [])
assert_equal('', t.evaluate(fact, []))
end
def test_sprintf
- t = Factbase::Term.new(:sprintf, ['hi, %s!', 'Jeff', :hey])
+ t = Factbase::Term.new(:sprintf, ['hi, %s!', 'Jeff'])
assert_equal('hi, Jeff!', t.evaluate(fact, []))
end
private