Change EdgeCase to Neo

This commit is contained in:
Jim Weirich
2013-04-09 10:40:27 -04:00
parent 67750bf9bf
commit 09b03e9b1c
33 changed files with 79 additions and 80 deletions

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutArrayAssignment < EdgeCase::Koan
class AboutArrayAssignment < Neo::Koan
def test_non_parallel_assignment
names = ["John", "Smith"]
assert_equal __(["John", "Smith"]), names

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutArrays < EdgeCase::Koan
class AboutArrays < Neo::Koan
def test_creating_arrays
empty_array = Array.new
assert_equal __(Array), empty_array.class

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
# -*- ruby -*-
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutAsserts < EdgeCase::Koan
class AboutAsserts < Neo::Koan
# We shall contemplate truth by testing reality, via asserts.
def test_assert_truth

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutBlocks < EdgeCase::Koan
class AboutBlocks < Neo::Koan
def method_with_block
result = yield
result

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutClassMethods < EdgeCase::Koan
class AboutClassMethods < Neo::Koan
class Dog
end

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutClasses < EdgeCase::Koan
class AboutClasses < Neo::Koan
class Dog
end

View File

@@ -1,8 +1,8 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
C = "top level"
class AboutConstants < EdgeCase::Koan
class AboutConstants < Neo::Koan
C = "nested"

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutControlStatements < EdgeCase::Koan
class AboutControlStatements < Neo::Koan
def test_if_then_else_statements
if true

View File

@@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
# Implement a DiceSet Class here:
#
@@ -15,7 +15,7 @@ class DiceSet
end
#++
class AboutDiceProject < EdgeCase::Koan
class AboutDiceProject < Neo::Koan
def test_can_create_a_dice_set
dice = DiceSet.new
assert_not_nil dice

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutExceptions < EdgeCase::Koan
class AboutExceptions < Neo::Koan
class MySpecialError < RuntimeError
end

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutHashes < EdgeCase::Koan
class AboutHashes < Neo::Koan
def test_creating_hashes
empty_hash = Hash.new
assert_equal __(Hash), empty_hash.class

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutInheritance < EdgeCase::Koan
class AboutInheritance < Neo::Koan
class Dog
attr_reader :name

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutIteration < EdgeCase::Koan
class AboutIteration < Neo::Koan
# -- An Aside ------------------------------------------------------
# Ruby 1.8 stores names as strings. Ruby 1.9 stores names as

View File

@@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
include Java
@@ -11,7 +11,7 @@ include Java
# * Calling custom java class
# * Calling Ruby from java???
class AboutJavaInterop < EdgeCase::Koan
class AboutJavaInterop < Neo::Koan
def test_using_a_java_library_class
java_array = java.util.ArrayList.new
assert_equal __(Java::JavaUtil::ArrayList), java_array.class

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutMethods < EdgeCase::Koan
class AboutMethods < Neo::Koan
def method_with_keyword_arguments(one: 1, two: 'two')
[one, two]

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutMessagePassing < EdgeCase::Koan
class AboutMessagePassing < Neo::Koan
class MessageCatcher
def caught?

View File

@@ -1,10 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
def my_global_method(a,b)
a + b
end
class AboutMethods < EdgeCase::Koan
class AboutMethods < Neo::Koan
def test_calling_global_methods
assert_equal __(5), my_global_method(2,3)

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutModules < EdgeCase::Koan
class AboutModules < Neo::Koan
module Nameable
def set_name(new_name)
@name = new_name

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutNil < EdgeCase::Koan
class AboutNil < Neo::Koan
def test_nil_is_an_object
assert_equal __(true), nil.is_a?(Object), "Unlike NULL in other languages"
end

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutObjects < EdgeCase::Koan
class AboutObjects < Neo::Koan
def test_everything_is_an_object
assert_equal __(true), 1.is_a?(Object)
assert_equal __(true), 1.5.is_a?(Object)

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutOpenClasses < EdgeCase::Koan
class AboutOpenClasses < Neo::Koan
class Dog
def bark
"WOOF"

View File

@@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
# Project: Create a Proxy Class
#
@@ -42,7 +42,7 @@ end
# The proxy object should pass the following Koan:
#
class AboutProxyObjectProject < EdgeCase::Koan
class AboutProxyObjectProject < Neo::Koan
def test_proxy_method_returns_wrapped_object
# NOTE: The Television class is defined below
tv = Proxy.new(Television.new)
@@ -135,7 +135,7 @@ class Television
end
# Tests for the Television class. All of theses tests should pass.
class TelevisionTest < EdgeCase::Koan
class TelevisionTest < Neo::Koan
def test_it_turns_on
tv = Television.new

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutRegularExpressions < EdgeCase::Koan
class AboutRegularExpressions < Neo::Koan
def test_a_pattern_is_a_regular_expression
assert_equal __(Regexp), /pattern/.class
end

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutSandwichCode < EdgeCase::Koan
class AboutSandwichCode < Neo::Koan
def count_lines(file_name)
file = open(file_name)

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutScope < EdgeCase::Koan
class AboutScope < Neo::Koan
module Jims
class Dog
def identify

View File

@@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used to calculate the
@@ -54,7 +54,7 @@ def score(dice)
#++
end
class AboutScoringProject < EdgeCase::Koan
class AboutScoringProject < Neo::Koan
def test_score_of_an_empty_list_is_zero
assert_equal 0, score([])
end

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutStrings < EdgeCase::Koan
class AboutStrings < Neo::Koan
def test_double_quoted_strings_are_strings
string = "Hello, World"
assert_equal __(true), string.is_a?(String)

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutSymbols < EdgeCase::Koan
class AboutSymbols < Neo::Koan
def test_symbols_are_symbols
symbol = :ruby
assert_equal __(true), symbol.is_a?(Symbol)

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutToStr < EdgeCase::Koan
class AboutToStr < Neo::Koan
class CanNotBeTreatedAsString
def to_s

View File

@@ -1,9 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
# You need to write the triangle method in the file 'triangle.rb'
require 'triangle.rb'
class AboutTriangleProject < EdgeCase::Koan
class AboutTriangleProject < Neo::Koan
def test_equilateral_triangles_have_equal_sides
assert_equal :equilateral, triangle(2, 2, 2)
assert_equal :equilateral, triangle(10, 10, 10)

View File

@@ -1,9 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
# You need to write the triangle method in the file 'triangle.rb'
require 'triangle.rb'
class AboutTriangleProject2 < EdgeCase::Koan
class AboutTriangleProject2 < Neo::Koan
# The first assignment did not talk about how to handle errors.
# Let's handle that part now.
def test_illegal_triangles_throw_exceptions

View File

@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutTrueAndFalse < EdgeCase::Koan
class AboutTrueAndFalse < Neo::Koan
def truth_value(condition)
if condition
:true_stuff

View File

@@ -83,8 +83,7 @@ class String
end
end
# TODO: Change EdgeCase to Neo
module EdgeCase
module Neo
class << self
def simple_output
ENV['SIMPLE_KOAN_OUTPUT'] == 'true'
@@ -196,7 +195,7 @@ module EdgeCase
@failure = step.failure
add_progress(@pass_count)
@observations << Color.red("#{step.koan_file}##{step.name} has damaged your karma.")
throw :edgecase_exit
throw :neo_exit
end
end
@@ -222,7 +221,7 @@ module EdgeCase
def show_progress
bar_width = 50
total_tests = EdgeCase::Koan.total_tests
total_tests = Neo::Koan.total_tests
scale = bar_width.to_f/total_tests
print Color.green("your path thus far [")
happy_steps = (pass_count*scale).to_i
@@ -238,7 +237,7 @@ module EdgeCase
end
def end_screen
if EdgeCase.simple_output
if Neo.simple_output
boring_end_screen
else
artistic_end_screen
@@ -275,7 +274,7 @@ module EdgeCase
,:::::::::::::, brought to you by ,,::::::::::::,
:::::::::::::: ,::::::::::::
::::::::::::::, ,:::::::::::::
::::::::::::, EdgeCase Software Artisans , ::::::::::::
::::::::::::, Neo Software Artisans , ::::::::::::
:,::::::::: :::: :::::::::::::
,::::::::::: ,: ,,:::::::::::::,
:::::::::::: ,::::::::::::::,
@@ -337,7 +336,7 @@ ENDTEXT
def find_interesting_lines(backtrace)
backtrace.reject { |line|
line =~ /test\/unit\/|edgecase\.rb|minitest/
line =~ /test\/unit\/|neo\.rb|minitest/
}
end
@@ -397,19 +396,19 @@ ENDTEXT
setup
begin
send(name)
rescue StandardError, EdgeCase::Sensei::AssertionError => ex
rescue StandardError, Neo::Sensei::AssertionError => ex
failed(ex)
ensure
begin
teardown
rescue StandardError, EdgeCase::Sensei::AssertionError => ex
rescue StandardError, Neo::Sensei::AssertionError => ex
failed(ex) if passed?
end
end
self
end
# Class methods for the EdgeCase test suite.
# Class methods for the Neo test suite.
class << self
def inherited(subclass)
subclasses << subclass
@@ -466,7 +465,7 @@ ENDTEXT
class ThePath
def walk
sensei = EdgeCase::Sensei.new
sensei = Neo::Sensei.new
each_step do |step|
sensei.observe(step.meditate)
end
@@ -474,9 +473,9 @@ ENDTEXT
end
def each_step
catch(:edgecase_exit) {
catch(:neo_exit) {
step_count = 0
EdgeCase::Koan.subclasses.each_with_index do |koan,koan_index|
Neo::Koan.subclasses.each_with_index do |koan,koan_index|
koan.testmethods.each do |method_name|
step = koan.new(method_name, koan.to_s, koan_index+1, step_count+=1)
yield step
@@ -488,6 +487,6 @@ ENDTEXT
end
END {
EdgeCase::Koan.command_line(ARGV)
EdgeCase::ThePath.new.walk
Neo::Koan.command_line(ARGV)
Neo::ThePath.new.walk
}