~singpolyma/dhall-ruby

ref: d79e79e33b434fb9dc21bbffcdc55662e6aeec7b dhall-ruby/test/test_cache_key.rb -rw-r--r-- 612 bytes
d79e79e3Stephen Paul Weber Add as_dhall refinement 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require "minitest/autorun"
require "pathname"

require "dhall"

class TestCacheKey < Minitest::Test
	DIRPATH = Pathname.new(File.dirname(__FILE__))
	TESTS = DIRPATH + "../dhall-lang/tests/semantic-hash/success/"

	Pathname.glob(TESTS + "**/*A.dhall").each do |path|
		test = path.relative_path_from(TESTS).to_s.sub(/A\.dhall$/, "")
		define_method("test_#{test}") do
			assert_equal(
				(TESTS + "#{test}B.hash").read.chomp,
				Dhall::Parser.parse_file(path).value.resolve(
					relative_to: Dhall::Import::Path.from_string(path)
				).then(&:cache_key).sync
			)
		end
	end
end