File: core_language/pattern/unit_test.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Umu#6
  module: Test#8
  module: Grammar#10
  module: CoreLanguage#12
  module: Pattern#14
  class: UnitTest#16
inherits from
  Test ( Minitest )
has properties
method: setup #20
method: test_value #25
method: test_should_be_unit_in_declaration #32
method: test_lambda #39
method: test_should_be_unit_in_lambda #46

Code

   1  # frozen_string_literal: true
   2 
   3  require "test_helper"
   4 
   5 
   6  module Umu
   7 
   8  module Test
   9 
  10  module Grammar
  11 
  12  module CoreLanguage
  13 
  14  module Pattern
  15 
  16  class UnitTest < Minitest::Test
  17  =begin
  18  <unit-pattern> ::= "(" ")" ;
  19  =end
  20      def setup
  21          @interp = Api.setup_interpreter
  22      end
  23 
  24 
  25      def test_value
  26          assert (
  27              Api.eval_decls @interp, "val () = ()"
  28          )
  29      end
  30 
  31 
  32      def test_should_be_unit_in_declaration
  33          assert_raises(X::TypeError) do
  34              Api.eval_decls @interp, "val () = 3"
  35          end
  36      end
  37 
  38 
  39      def test_lambda
  40          value = Api.eval_expr @interp, "{ () -> 3 } ()"
  41          assert_instance_of VCAN::Int, value
  42          assert_equal       3,         value.val
  43      end
  44 
  45 
  46      def test_should_be_unit_in_lambda
  47          assert_raises(X::TypeError) do
  48              Api.eval_expr @interp, "{ () -> 3 } 4"
  49          end
  50      end
  51  end
  52 
  53  end # Umu::Test::Grammar::CoreLanguage::Pattern
  54 
  55  end # Umu::Test::Grammar::CoreLanguage
  56 
  57  end # Umu::Test::Grammar
  58 
  59  end # Umu::Test
  60 
  61  end # Umu