On 2007-12-14, Ruby Quiz <james / grayproductions.net> wrote:
[--snip--]
> 	The Serve
The Pong

> The initial contents of avl_tree.rb are:
The altered contents of avl_tree.rb are:

#!/usr/bin/env ruby -wKU                                                

class AVLTree                                                           
  attr_accessor :head
  def initialize
    @head = nil
  end
  def empty?
    @head.nil?
  end
  def << (thing)
    @head = thing if empty?
  end
  def include?(value)
    @head == value
  end
end     

> The test file, test_avl_tree.rb, begins as:
The test file was altered as:

#!/usr/bin/env ruby -wKU                                                

require "test/unit"                                                     

require "avl_tree"                                                      

class TestAVLTree < Test::Unit::TestCase                                
  def setup                                                             
    @tree = AVLTree.new                                                 
  end                                                                   

  def test_tree_membership                                              
    assert_equal(true, @tree.empty?)                                   
    assert_equal(false, @tree.include?(3))                              

    @tree << 3                                                          

    assert_equal(false, @tree.empty?)                                   
    assert_equal(true, @tree.include?(3))
  end                                                                   

  def test_tree_insertion
    assert_equal(true, @tree.empty?)                                   
    assert_equal(false, @tree.include?(3))                              
    assert_equal(false, @tree.include?(5))

    @tree << 3
    @tree << 5

    assert_equal(false, @tree.empty?)                                   
    assert_equal(true, @tree.include?(5))
    assert_equal(true, @tree.include?(3))
  end
end        

Hope this follows the rules as the insertion is not actually implemented
nor is the include?. But I guess in less than 20 lines that's the best a
`Pong' can do (-:
-- 
everything is simple, we're stupid
contact at gmail