start_up = proc ()
    % testOB color_t
    print("*****color_t*****\n")
    test_color()
    
    % test piece_t
    print("*****piece_t*****\n")
    test_piece()
    
    % test place_t
    print("*****place_t*****\n")
    test_place()
    
    % test stack_t
    print("*****stack_t*****\n")
    test_stack()
    
    % test move_t
    print("*****move_t*****\n")
    test_move()
    
    % test board_t
    print("*****board_t*****\n")
    test_board()
    
    end start_up

  
  test_color = proc()
      % effects: Tests the color_t cluster
      
      % Note there are three objects of this type.
      % I will test this cluster in groups of similar operators.
      % i.e. test make_white, make_black, make_none in one section of
      % code so for readablity.
      % Also you may note that there are few glass box tests,
      % this is due to the simplicity of the rep.
      
      % make_white
      % make_black
      % make_none
      %
      % Black Box
      %
      % Create an object of each type, using the results will
      % confirm that the make procedures work.
      
      white : color_t := color_t$make_white()      
      black : color_t := color_t$make_black()      
      none_col : color_t := color_t$make_none()
      
      % Glass Box
      % 
      % No further tests should be nessesary
      
      % is_white
      % is_black
      % is_none
      %
      % Black Box
      % make sure objects created before were created properly.
      assert("is_white",color_t$is_white(white))
      assert("is_black",color_t$is_black(black))
      assert("is_none",color_t$is_none(none_col))
      
      % Glass Box
      % 
      % No further tests should be nessesary
      
      % is_opposite
      %
      % Black Box 
      % test when one is black and other is white.
      % test when both same color.
      
      assert("is_opposite black & white",color_t$is_opposite(black,white))
      black_2 : color_t := color_t$make_black()
      assert("is_opposite of black,black",
	     color_t$is_opposite(black,black_2) = false)
      
      % Glass Box
      %
      % test when both colors are none
      
      none_2 : color_t := color_t$make_none()
      assert("is_opposite of none,none",
	     color_t$is_opposite(none_col,none_2) = false)
      
      % opposite
      %
      % Black Box
      % 
      % test for white
      % test for black
      % test for none

      assert("opposite white",color_t$is_black(color_t$opposite(white)))
      assert("opposite black",color_t$is_white(color_t$opposite(black)))
      assert("opposite none",color_t$is_none(color_t$opposite(none_col)))
      
      % Glass Box
      %
      % No further tests should be nessesary
      
      % equal
      %
      % Black Box
      %
      % test when same object
      % test when same color but different object
      assert("same object",black = black)
      assert("same color",none_col = none_2)
      
    end test_color
  
  test_piece = proc()
      % effects:  Tests the piece_t cluster.
      
      % colors for later use
      white : color_t := color_t$make_white()
      black : color_t := color_t$make_black()
      none_col : color_t := color_t$make_none()
      
      % create
      %
      % Black Box
      %
      % test by createing a few pieces and testing them by using them 
      % in later tests. Pieces will be created later also.
      white_king : piece_t := piece_t$create(king,white)
      black_pawn : piece_t := piece_t$create(pawn,black)
      no_piece : piece_t := piece_t$create(none,none_col)
      
      % Glass Box
      %
      % No further tests should be nessesary
      
      % parse
      %
      % Black Box
      % 
      % parse a white piece char
      % parse a black piece char
      % parse an empty square char
      % invalid parse
      
      piece_K : piece_t := piece_t$parse('K')
      assert("parse white king",white_king = piece_K)
      
      piece_p : piece_t := piece_t$parse('p')
      assert("parse black pawn",black_pawn = piece_p)
      
      piece_no : piece_t := piece_t$parse('-')
      assert("parse empty square",no_piece = piece_no)
      
      ok_flag : bool := false
      piece_invalid : piece_t := piece_t$parse('y')
       except when invalid: ok_flag := true
	end
      assert("invalid piece parse",ok_flag)
      
      % Glass Box
      %
      % check white pawn since it is at the high bound of the
      % own array in the cluster.
      
      piece_wP : piece_t := piece_t$parse('P')
      white_pawn : piece_t := piece_t$create(pawn,white)
      assert("parse white king",white_pawn = piece_wP)
      
      % unparse
      % 
      % Black Box
      %
      % test unparse black piece
      % test unparse white piece
      % test unparse empty square piece
      
      assert("unparse white king",piece_t$unparse(white_king) = 'K')
      assert("unparse black pawn",piece_t$unparse(black_pawn) = 'p')
      assert("unparse white king",piece_t$unparse(no_piece) = '-')
      
      % Glass Box
      %
      % No further tests should be nessesary
      
      % get_piecetype
      %
      % Black Box
      %
      % test by getting the piece type of a piece
      
      assert("get_piecetype", white_king.piecetype = king) 
      
      % Glass Box
      %
      % No further tests should be nessesary
      
      % get_color
      %
      % Black Box
      %
      % test by getting the color of a piece
      
      assert("get_piecetype", no_piece.color = none_col) 
      
      % Glass Box
      %
      % No further tests should be nessesary
      
      % equal
      %
      % Black Box
      %
      % this should have been checked by previous tests
      % I will only test it further with glass box tests
      
      % Glass Box
      %
      % test when types are the same but colors are not
      % test when colors are the same but types are not
      assert("equal same piecetype",(white_pawn = black_pawn) = false)
      
      assert("equal same color",(white_pawn = white_king) = false)
      
    end test_piece
  
  
  test_place = proc()
      % effects:  Tests the place_t cluster.
      
      % create
      %
      % Black Box
      %
      % this will be tested by creating a few objects of
      % type place_t and useing them in later tests
      % 
      % test invalid place
      
      ok_flag : bool := true
      g3 : place_t := place_t$create(3,7)
       except when invalid:
	  ok_flag := false
	end
      assert("create",ok_flag)
      
      ok_flag := false
      place_t$create(9,1)
       except when invalid:
	  ok_flag := true
	end
      assert("Invalid place",ok_flag)
      
      % Glass Box
      %
      % test when row is too big
      % test when col is too big
      % test when row is too small
      % test when col is too small
      % test lower limits
      % test upper limits
      
      % test when row is too big
      ok_flag := false
      place_t$create(9,1)
       except when invalid:
	  ok_flag := true
	end
      assert("row too big",ok_flag)
      
      % test when col is too big
      ok_flag := false
      place_t$create(8,9)
       except when invalid:
	  ok_flag := true
	end
      assert("col too big",ok_flag)
      
      % test when row is too small
      ok_flag := false
      place_t$create(0,1)
       except when invalid:
	  ok_flag := true
	end
      assert("row too small",ok_flag)
      
      % test when col is too small
      ok_flag := false
      place_t$create(8,0)
       except when invalid:
	  ok_flag := true
	end
      assert("col too small",ok_flag)
      
      % test lower limits
      ok_flag := true
      place_t$create(1,1)
       except when invalid:
	  ok_flag := false
	end
      assert("row = 1 col = 1",ok_flag)
      
      % test upper limits
      ok_flag := true
      place_t$create(8,8)
       except when invalid:
	  ok_flag := false
	end
      assert("row = 8 col = 8",ok_flag)
      
      
      % parse 
      %
      % Black Box
      % 
      % test uppercase letter in place string
      % test lowercase letter in place string
      % test invalid place string
      
      upper_g3 : place_t := place_t$parse("G3")
      assert("parse G3",upper_g3 = g3)
      
      lower_g3 : place_t := place_t$parse("g3")
      assert("parse g3",lower_g3 = g3)
      
      ok_flag := false
      place_t$parse("3g")
       except when invalid:
	  ok_flag := true
	end
      assert("invalid place string",ok_flag)
      
      % Glass Box
      %
      % test row out of bounds
      % test col out of bounds
      % test 'a' row
      % test 'h' row
      % test 'H' row
      
      ok_flag := false
      place_t$parse("g9")
       except when invalid:
	  ok_flag := true
	end
      assert("row out of bounds",ok_flag)
      
      ok_flag := false
      place_t$parse("j2")
       except when invalid:
	  ok_flag := true
	end
      assert("col out of bounds",ok_flag)
      
      assert("parse a8",place_t$parse("a8")=place_t$create(8,1))

      assert("parse h8",place_t$parse("h8")=place_t$create(8,8))
      
      assert("parse H8",place_t$parse("H8")=place_t$create(8,8))
      
      % unparse
      %
      % Black Box
      % test by unparseing a place
      
      assert("unparse g3",place_t$unparse(g3) = "g3")
            
      % Glass Box
      %
      % test for row = 'a'
      a1 : place_t := place_t$create(1,1)
      assert("unparse a1",place_t$unparse(a1) = "a1")
      
      % get_row
      %
      % Black Box
      % get row of a place
      assert("get_row",g3.row = 3)
      
      % Glass Box
      %
      % No further tests should be nessesary
      
      % get_col
      %
      % Black Box
      
      assert("get_col",g3.col = 7)
      
      % Glass Box
      %
      % No further tests should be nessesary
      
      % equal
      %
      % Black Box
      % test when equal
      assert("equal",place_t$create(3,4) = place_t$create(3,4))
      
      % Glass Box
      %
      % test when cols are equal
      % test when rows are equal
      % test when niether is equal
      
      assert("equal",(place_t$create(3,4) = place_t$create(5,4)) = false)
      assert("equal",(place_t$create(3,4) = place_t$create(3,7)) = false)
      assert("equal",(place_t$create(3,4) = place_t$create(4,3)) = false)
      
      
    end test_place

test_stack = proc()
    % a few initial variables
    intstack = stack_t[int]
    x,y,z:int
    okay : bool 
    
    %CREATE    
    % this can only try to create.. the rest of the test will
    % come with the other tests. If create is wrong none of the others
    % should work
    st1 : intstack := intstack$create()
    st2 : intstack := intstack$create()
    % END CREATE
    
    % PUSH/POP
    % this will try to push elements and pop them. Also try the
    % empty stack
    % initial stack
       okay := false
       x := intstack$pop(st1) except when empty: okay := true end
       assert("pop on empty", okay)
       intstack$push(st1, 5)   % first element should be a five
       intstack$push(st1, 6)   % we should pop off a six first
       assert("pop", ((intstack$pop(st1) = 6) & (intstack$pop(st1) = 5)))
       okay := false
       intstack$pop(st1) 
	except when empty: okay := true end
       assert("pop", okay)
       intstack$push(st1, 5)   % first element should be a five
       intstack$push(st1, 6)   % we should pop off a six first
       intstack$pop(st1)       % get rid of the six
       intstack$push(st1, 2)   % stack should be 2 over 5
       assert("pop", ((intstack$pop(st1) = 2) & (intstack$pop(st1) = 5)))
    % end PUSH/POP
    
    % COPY
    % this will make a copy of an empty stack. test it. Then, a copy of a
    % stack with one element, and test it.
      st3:intstack := intstack$copy(st1)  % st1 is empty
      okay := false
      intstack$pop(st3) except when empty: okay := true end
      assert("copy", okay)
      intstack$push(st1, 5)
      st3 := intstack$copy(st1)   % st3 should also have a 5 but be seperate
      assert("copy", (intstack$pop(st3) = 5) & (intstack$pop(st1) = 5))
    % copy a stack with 2 elements
      st4 : intstack := intstack$create()
      intstack$push(st4,1)
      intstack$push(st4,2)
      st5 : intstack := intstack$copy(st4)
      assert("copy part 1",(intstack$pop(st4) = 2) & (intstack$pop(st5) = 2))
      assert("copy part 2",(intstack$pop(st4) = 1) & (intstack$pop(st5) = 1))
      ok1:bool := false
      ok2:bool := false
      intstack$pop(st4)
       except when empty:
	  ok1 := true
	end
      intstack$pop(st4)
       except when empty:
	  ok2 := true
	end
      assert("copy: both empty",(ok1 = true) & (ok2 = true)) 
      
      
      
    % END COPY
    
    % EMPTY
    % this will test an empty stack and a non-empty stack
    	assert("empty", intstack$empty(st2))
	intstack$push(st2, 10)
	assert("empty", ~intstack$empty(st2))
    % END EMPTY
    
    % PEEK
    % this will peek at an empty stack, a one element stack, and a 
    % three element stack.  st2 currently has a 10 in it
    % one element:
    	assert("peek", ((intstack$peek(st2) = 10) &
			(intstack$pop(st2) = 10)))
    % zero elements
    	okay := false
	intstack$peek(st2) except when empty: okay := true end
	assert("peek",okay)
    % three elements
    	intstack$push(st2, 1)
	intstack$push(st2, 2)
	intstack$push(st2, 3)
    	assert("peek", (((intstack$peek(st2) = 3) &
			 (intstack$pop(st2) = 3)) &
		        ((intstack$peek(st2) = 2) &
			 (intstack$pop(st2) = 2)) &
		        ((intstack$peek(st2) = 1) &
			 (intstack$pop(st2) = 1))))
     % END PEEK
     
     % DEPTH
     % this will try a zero, 1 and 3 element stack
     	assert("depth", intstack$depth(st2) = 0)
	intstack$push(st2, 1)
	assert("depth", intstack$depth(st2) = 1)
	intstack$push(st2, 2)
	intstack$push(st2, 3) 
	assert("depth", intstack$depth(st2) = 3)
     % END DEPTH     
  
    end test_stack
  
  
  test_move = proc()
    end test_move
  
  test_board = proc()
      
    % This is designed to test the board implementation.  It is black box.
    
    out:stream := stream$primary_output()
    board:board_t
    piece:piece_t
    place:place_t
    color:color_t
    mystr:string := "rnbqkbnr\npppppppp\n--------\n--------\n--------\n--------\nPPPPPPPP\nRNBQKBNR\n"
    
    
    stream$putl(out,"Testing parse/unparse:")
    board :=  board_t$parse(mystr)
     except when invalid :
	stream$putl(out,"\tFAILED! (on parse)")
      end % except
    
    if board_t$unparse(board)=mystr then
	stream$putl(out,"\tPassed. :)")
      else
	stream$putl(out,"\tFAILED (on unparse)")
	print(board_t$unparse(board))
      end % if
    
    
    stream$putl(out,"Testing board fetch:")
    color:= color_t$make_white()
    place:=place_t$create(1,4);
    piece := piece_t$create(queen,color)
    if board_t$fetch(board,place)=piece then
	stream$putl(out,"Passed. :)")
      else
	stream$putl(out,"FAILED!")
      end % if
    
    
    stream$putl(out,"Testing board fetch:")
    place:=place_t$create(8,5);
    board_t$store(board,place,piece)
    if board_t$fetch(board,place) = piece then
	stream$putl(out,"Passed! :)")
      else
	stream$putl(out,"FAILED!")
      end % if

      end test_board
    


assert = proc(message: string, test: bool)
    % effects: If test is true, prints message: OK,
    %                           else prints message: OOPS
    print(message)
    if test then print (": OK\n") else print (": OOPS\n") end
    end assert

print = proc (s:string)
    stream$puts(stream$primary_output(),s)
    end print



