File: core_language/expression/atomic/constant_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: Expression#14
  module: Atomic#16
  class: ConstantTest#18
inherits from
  Test ( Minitest )
has properties
method: setup #31
method: test_int #36
method: test_float #43
method: test_string #50
method: test_symbol #57
method: test_file_identifier #64
method: test_line_identifier #70

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 Expression
  15 
  16  module Atomic
  17 
  18  class ConstantTest < Minitest::Test
  19  =begin
  20  <constant> ::= 
  21      INT
  22    | FLOAT
  23    | STRING
  24    | SYMBOL
  25    | __FILE__
  26    | __LINE__
  27    ;
  28  =end
  29 
  30 
  31      def setup
  32          @interp = Api.setup_interpreter
  33      end
  34 
  35 
  36      def test_int
  37          value = Api.eval_expr @interp, "3"
  38          assert_instance_of  VCAN::Int, value
  39          assert_equal        3,         value.val
  40      end
  41 
  42 
  43      def test_float
  44          value = Api.eval_expr @interp, "3.4"
  45          assert_instance_of  VCAN::Float, value
  46          assert_equal        3.4,         value.val
  47      end
  48 
  49 
  50      def test_string
  51          value = Api.eval_expr @interp, '"apple"'
  52          assert_instance_of  VCA::String, value
  53          assert_equal        "apple",     value.val
  54      end
  55 
  56 
  57      def test_symbol
  58          value = Api.eval_expr @interp, "@apple"
  59          assert_instance_of  VCA::Symbol, value
  60          assert_equal        :apple,      value.val
  61      end
  62 
  63 
  64      def test_file_identifier
  65          value = Api.eval_expr @interp, "__FILE__"
  66          assert_instance_of  VCA::String, value
  67      end
  68 
  69 
  70      def test_line_identifier
  71          value = Api.eval_expr @interp, "__LINE__"
  72          assert_instance_of  VCAN::Int, value
  73      end
  74  end
  75 
  76  end # Umu::Test::Grammar::CoreLanguage::Expression::Atomic
  77 
  78  end # Umu::Test::Grammar::CoreLanguage::Expression
  79 
  80  end # Umu::Test::Grammar::CoreLanguage
  81 
  82  end # Umu::Test::Grammar
  83 
  84  end # Umu::Test
  85 
  86  end # Umu