Sha256: 4f4e960d0a19cc7e9cb60531f4fd9ff992b2eab75837a828088f4822103766aa

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

#!/usr/bin/env ruby

require 'test_helper'
require 'protocol/core'

class ProtocolCoreTest < Test::Unit::TestCase
  def test_comparing_numeric
    assert Numeric.conform_to?(Comparing)
  end

  def test_comparing_complex
    assert_false BasicObject.conform_to?(Comparing)
  end

  def test_comparing_array
    assert Array.conform_to?(Comparing)
  end

  def test_comparing_string
    assert String.conform_to?(Comparing)
  end

  def test_enumerating_array
    assert Array.conform_to?(Enumerating)
  end

  def test_enumerating_float
    assert_false Float.conform_to?(Enumerating)
  end

  def test_enumerating_hash
    assert Hash.conform_to?(Enumerating)
  end

  def test_indexing_array
    assert Array.conform_to?(Indexing)
  end

  def test_indexing_proc
    assert_false Proc.conform_to?(Indexing)
  end

  def test_indexing_hash
    assert Hash.conform_to?(Indexing)
  end

  def test_sychronizing_mutex
    assert Mutex.conform_to?(Synchronizing)
  end

  def test_sychronizing_hash
    assert_false Hash.conform_to?(Synchronizing)
  end

  def test_my_synchronizer
    s = Class.new do
      def initialize
        @lock = false
      end

      def lock
        @lock = true
      end

      def locked?
        @lock
      end

      def unlock
        @lock = false
      end

      conform_to Synchronizing
    end.new
    assert_false s.locked?
    s.synchronize { assert s.locked? }
    assert_false s.locked?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
protocol-2.0.1 tests/protocol_core_test.rb