~singpolyma/dhall-ruby

ref: 43890aec4916d92fd9f40b523d1024c824ebb7ac dhall-ruby/test/test_as_json.rb -rw-r--r-- 750 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
# frozen_string_literal: true

require "minitest/autorun"
require "pathname"
require "cbor"

require "dhall/ast"
require "dhall/binary"

class TestAsJson < 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$/, "")
		next if test =~ /binary-decode/
		define_method("test_#{test}") do
			skip "double as_json" if test =~ /doubleB/
			skip "deprecated syntax" if test =~ /collectionImportTypeB|annotationsB/
			skip "deprecated syntax" if test =~ /pathTerminationUnion/
			assert_equal(
				CBOR.decode(path.read),
				Dhall.from_binary(path.read).as_json
			)
		end
	end
end