~singpolyma/dhall-ruby

ref: 43890aec4916d92fd9f40b523d1024c824ebb7ac dhall-ruby/test/test_binary.rb -rw-r--r-- 878 bytes View raw
43890aecStephen Paul Weber Typecheck while resolving 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require "base64"
require "minitest/autorun"
require "pathname"

require "dhall"

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

	Pathname.glob(TESTS + "**/*.dhallb").each do |path|
		test = path.relative_path_from(TESTS).to_s.sub(/.dhallb$/, "")
		define_method("test_#{test}") do
			assert_kind_of(
				Dhall::Expression,
				Dhall.from_binary(path.binread)
			)
		end
	end

	DECODE_TESTS = DIRPATH + "../dhall-lang/tests/binary-decode/success/"
	Pathname.glob(DECODE_TESTS + "**/*A.dhallb").each do |path|
		test = path.relative_path_from(DECODE_TESTS).to_s.sub(/A.dhallb$/, "")
		define_method("test_#{test}") do
			assert_equal(
				Dhall::Parser.parse_file(DECODE_TESTS + "#{test}B.dhall").value,
				Dhall.from_binary(path.binread)
			)
		end
	end
end