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