Skip to content

Instantly share code, notes, and snippets.

@soutaro
Created February 10, 2012 02:42
Show Gist options
  • Save soutaro/1785776 to your computer and use it in GitHub Desktop.
Save soutaro/1785776 to your computer and use it in GitHub Desktop.
Test codes for unification
require "test_helper"
require "unifier_assertion"
class UnifierAssertionTest < ActiveSupport::TestCase
include UnifierAssertion
test "unifier" do
assert_equal({:"'a" => 1 },
unify([[
[1,2,3],
[:"'a",2,3]
]]))
assert_equal({:"'a" => "':b" },
unify([[
["':b",2,3],
[:"'a",2,3]
]]))
assert_equal({:"'a" => [1]},
unify([
[:"'a", [1]]
]))
assert_equal({:"'a" => [1], :"'b" => [1]},
unify([
[:"'a", [1]],
[:"'b", :"'a"]]))
assert_equal({:"'a" => Time.new(2011,1,1) },
unify([[
{ :created_at => :a, :updated_at => :"'a", },
{ :created_at => Time.new(2011,1,1), :updated_at => Time.new(2011,1,1) },
]]))
assert_nil(unify([[
{ :created_at => :"'a", :updated_at => :"'a", },
{ :created_at => Time.new(2011,1,1), :updated_at => Time.new(2011,1,2) },
]]))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment