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