###################################################################### # # Tests for miscellaneous methods specific to individual Node classes. # ###################################################################### require 'test_helper' class MiscTests < Minitest::Test # ------------------------------------------------------------------ # Declarator#declaration type # ------------------------------------------------------------------ def test_declarator_declaration tor = C::Declarator.new(nil, 'x') assert_nil(tor.declaration) list = C::NodeArray[tor] assert_nil(tor.declaration) tion = C::Declaration.new(C::Int.new, list) assert_same(tion, tor.declaration) list.detach assert_nil(tor.declaration) end def test_declarator_type # int i, *j, k[], l(), *m[10]; decl = C::Declaration.new(C::Int.new) decl.declarators << C::Declarator.new(nil, 'i') decl.declarators << C::Declarator.new(C::Pointer.new, 'j') decl.declarators << C::Declarator.new(C::Array.new, 'k') decl.declarators << C::Declarator.new(C::Function.new, 'l') arr = C::Array.new(C::Pointer.new, C::IntLiteral.new(10)) decl.declarators << C::Declarator.new(arr, 'm') assert_equal_inspect_strs(decl.declarators[0].type.inspect, <