~singpolyma/dhall-ruby

7f98d0a96d77eb44af1ca979f9ae2319a2af8db0 — Stephen Paul Weber 2 years ago 2a3d4e2
Fix Proc decode
2 files changed, 9 insertions(+), 1 deletions(-)

M lib/dhall/coder.rb
M test/test_coder.rb
M lib/dhall/coder.rb => lib/dhall/coder.rb +1 -1
@@ 117,7 117,7 @@ module Dhall

			refine Function do
				def to_ruby(&decode)
					->(*args) { decode[expr.call(*args)] }
					->(*args) { decode[call(*args)] }
				end
			end


M test/test_coder.rb => test/test_coder.rb +8 -0
@@ 155,6 155,14 @@ class TestCoder < Minitest::Test
		end
	end

	def test_decode_proc
		coder = Dhall::Coder.new(safe: [Proc, NilClass, Integer])
		assert_equal(
			2,
			coder.decode(Dhall.load("\\(x: Natural) -> x + 1").sync).call(1)
		)
	end

	class Custom
		attr_reader :a, :b