Sha256: 7efc4166945b00cbc4551a61ef9316da69cc5af8b4371e9c4a9921b5ec9970a1

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require 'helper'

class TestParserEvaluator < Test::Unit::TestCase
  
  HUGE_SCRIPT = File.open(File.dirname(__FILE__) + "/test-data/huge_nuke_tcl.tcl")
  NUKE7_SCRIPT = File.open(File.dirname(__FILE__) + "/test-data/nuke7_tracker_2tracks.nk")
  MISSING_LF = File.open(File.dirname(__FILE__) + 
    "/test-data/nuke8_copypaste_without_linefeed_at_end.nk")
  
  class Tracker4
    attr_reader :knobs
    def initialize(knobs)
      @knobs = knobs
    end
  end
  
  class NodeCaptured < RuntimeError; end
  
  def test_processes_nodes
    pe = Tickly::NodeProcessor.new
    pe.add_node_handler_class(Tracker4)
    
    assert_raise(NodeCaptured) do
      pe.parse(NUKE7_SCRIPT) do | node |
        assert_kind_of Tracker4, node
        assert_equal "Tracker1", node.knobs["name"]
        
        raise NodeCaptured
      end
    end
  end
  
  def test_processes_without_trailing_LF
    pe = Tickly::NodeProcessor.new
    pe.add_node_handler_class(Tracker4)
    
    assert_raise(NodeCaptured) do
      pe.parse(MISSING_LF) do | node |
        
        assert_kind_of Tracker4, node
        ref_knobs = {"ypos"=>"-177"}
        assert_equal ref_knobs, node.knobs
        
        raise NodeCaptured
      end
    end
  end
  
  def test_raises_without_a_block
    pe = Tickly::NodeProcessor.new
    assert_raise(LocalJumpError) { pe.parse(NUKE7_SCRIPT) }
  end
  
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tickly-2.1.7 test/test_node_processor.rb
tickly-2.1.6 test/test_node_processor.rb
tickly-2.1.5 test/test_node_processor.rb
tickly-2.1.4 test/test_node_processor.rb