Sha256: 5339172ca681df4a16692dc63e94b42a7298559466af8006bd5f6209255c9c4a

Contents?: true

Size: 746 Bytes

Versions: 1

Compression:

Stored size: 746 Bytes

Contents

$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'erlectricity'
require 'rubygems'
require 'test/unit'
require 'test/spec'

class Test::Unit::TestCase
  
  def run_erl(code)
    `erl -noshell -eval 'A = #{code.split.join(' ')}, io:put_chars(A).' -s erlang halt`
  end
  
  def encode_packet(code)
    bin = run_erl("term_to_binary(#{code})")
    [bin.length, bin].pack("Na#{bin.length}")
  end
  
  def word_length
    (1.size * 8) - 2
  end
end

class FakePort < Erlectricity::Port
  attr_reader :sent
  attr_reader :terms
  
  def initialize(*terms)
    @terms = terms
    @sent = []
    super(StringIO.new(""), StringIO.new(""))
  end

  def send(term)
    sent << term
  end
  
  private
  def read_from_input
    @terms.shift
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
erlectricity-0.2.0 test/test_helper.rb