Project

General

Profile

Backport #5876 » testModule.rb

nlgunther (Nick Gunther), 01/11/2012 05:59 AM

 
require 'OtherFileWithModules'
puts `ruby -v`
module TestModule
class Array
include ArrayMethods
end
class Test # The main class to hold rate data from a report in a tabular format
def initialize
ar = [1,2]
# allow for Hash values of the form [regexp, capture group number = 0]
puts "Compare the results for Testing Equivalences of \nClasses and Classes Converted to String:"
puts "******"
puts "Testing Class Equivalence:"
if ar.class != Array
puts "The class is an array: #{ar.class}"
puts "But we're in the branch where array class equivalence\ntested false, so there's a problem!"
else
puts "No Problem"
end
puts 'WORKAROUND: Testing Equivalence After Converting to Strings:'
if ar.class.to_s != 'Array'
puts ar.class
puts "There's a problem!"
else
puts "No Problem"
end
end
end
end
class Array
include ArrayMethods
end
class Test # The main class to hold rate data from a report in a tabular format
def initialize
ar = [1,2]
# allow for Hash values of the form [regexp, capture group number = 0]
puts "Class and Class Converted to String:"
puts "******"
puts "Testing Class Equivalence"
if ar.class != Array
puts "The class is an array: #{ar.class}"
puts "But we're in the branch where array class equivalence\ntested false, so there's a problem!"
else
puts "No Problem"
end
puts 'Testing Equivalence After Converting to Strings'
if ar.class.to_s != 'Array'
puts ar.class
puts "A problem"
else
puts "No Problem"
end
end
end
puts "FIRST: Testing Within a Module: Displays the Problem and the Workaround\n = Converting to Strings"
puts
TestModule::Test.new
puts "SECOND: Testing Outside a Module: No problem"
puts
Test.new
(2-2/3)