~singpolyma/dhall-ruby

9a8ad3a23c693e3d2dac10793f201857667b96eb — Stephen Paul Weber 5 years ago 4601095
as_dhall for Symbol
2 files changed, 22 insertions(+), 1 deletions(-)

M lib/dhall/as_dhall.rb
M test/test_as_dhall.rb
M lib/dhall/as_dhall.rb => lib/dhall/as_dhall.rb +10 -0
@@ 39,6 39,16 @@ module Dhall
			end
		end

		refine ::Symbol do
			def as_dhall
				Dhall::Union.new(
					tag:          to_s,
					value:        nil,
					alternatives: Dhall::UnionType.new(alternatives: {})
				)
			end
		end

		refine ::Integer do
			def as_dhall
				if negative?

M test/test_as_dhall.rb => test/test_as_dhall.rb +12 -1
@@ 2,7 2,7 @@

require "minitest/autorun"

require "dhall/as_dhall"
require "dhall"

class TestAsDhall < Minitest::Test
	using Dhall::AsDhall


@@ 24,6 24,17 @@ class TestAsDhall < Minitest::Test
		end
	end

	def test_symbol
		assert_equal(
			Dhall::Union.new(
				tag:          "hai",
				value:        nil,
				alternatives: Dhall::UnionType.new(alternatives: {})
			),
			:hai.as_dhall
		)
	end

	def test_natural
		assert_equal Dhall::Natural.new(value: 1), 1.as_dhall
	end