~singpolyma/dhall-ruby

7af3c97cd14e3e1e22fa35fa56f86f00501a27d6 — Stephen Paul Weber 3 years ago f8217b0
Run tests per docs
2 files changed, 12 insertions(+), 13 deletions(-)

M lib/dhall/typecheck.rb
M test/test_typechecker.rb
M lib/dhall/typecheck.rb => lib/dhall/typecheck.rb +5 -9
@@ 620,9 620,9 @@ module Dhall
				annotated_value = @value.annotate(context)

				type = Dhall::UnionType.new(
					alternatives: Hash[@union.alternatives.alternatives.merge(
						@union.tag => annotated_value.type
					).sort]
					alternatives: { @union.tag => annotated_value.type }.merge(
						@union.alternatives.alternatives
					)
				)

				# Annotate to sanity check


@@ 800,13 800,9 @@ module Dhall
					                 "#{@let.type}, #{aassign.type}"
				end

				Dhall::Function.disable_alpha_normalization!
				nassign = @let.assign.normalize.shift(1, @let.var, 0)
				Dhall::Function.enable_alpha_normalization!

				abody = TypeChecker.for(@letblock.body.substitute(
					Dhall::Variable[@let.var],
					nassign
					@let.assign.shift(1, @let.var, 0)
				).shift(-1, @let.var, 0)).annotate(context)

				ablock = @letblock.with(


@@ 832,7 828,7 @@ module Dhall
			def annotate(context)
				redo_annotation = TypeChecker.for(@expr.value).annotate(context)

				if redo_annotation.type == @expr.type
				if redo_annotation.type.normalize == @expr.type.normalize
					redo_annotation
				else
					raise TypeError, "TypeAnnotation does not match: " \

M test/test_typechecker.rb => test/test_typechecker.rb +7 -4
@@ 15,11 15,14 @@ class TestTypechecker < Minitest::Test
		next if test =~ /prelude/

		define_method("test_#{test}") do
			assert_equal(
				Dhall.from_binary((TESTS + "#{test}B.dhallb").binread),
			assert_kind_of(
				Dhall::TypeAnnotation,
				Dhall::TypeChecker.for(
					Dhall.from_binary(path.binread)
				).annotate(Dhall::TypeChecker::Context.new).type
					Dhall::TypeAnnotation.new(
						value: Dhall.from_binary(path.binread),
						type:  Dhall.from_binary((TESTS + "#{test}B.dhallb").binread)
					)
				).annotate(Dhall::TypeChecker::Context.new)
			)
		end
	end