Project

General

Profile

Backport #5876 ยป testModule.rb

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

 
1
require 'OtherFileWithModules'
2
puts `ruby -v`
3
module TestModule
4
	class Array
5
		include ArrayMethods
6
	end
7
	class Test # The main class to hold rate data from a report in a tabular format
8
		def initialize
9
			ar = [1,2]
10
			# allow for Hash values of the form [regexp, capture group number = 0]
11
			puts "Compare the results for Testing Equivalences of \nClasses and Classes Converted to String:"
12
			puts  "******"
13
			puts "Testing Class Equivalence:"
14
			if ar.class != Array
15
				puts "The class is an array: #{ar.class}"
16
				puts "But we're in the branch where array class equivalence\ntested false, so there's a problem!"
17
			else 
18
				puts "No Problem"			
19
			end
20
			puts 'WORKAROUND: Testing Equivalence After Converting to Strings:'
21
			if ar.class.to_s != 'Array'
22
				puts ar.class
23
				puts "There's a problem!"
24
			else 
25
				puts "No Problem"			
26
			end			
27
		end	
28
	end
29
end
30
class Array
31
		include ArrayMethods
32
end
33
class Test # The main class to hold rate data from a report in a tabular format
34
	def initialize
35
		ar = [1,2]
36
			# allow for Hash values of the form [regexp, capture group number = 0]
37
		puts "Class and Class Converted to String:"
38
		puts  "******"
39
		puts "Testing Class Equivalence"
40
		if ar.class != Array
41
				puts "The class is an array: #{ar.class}"
42
				puts "But we're in the branch where array class equivalence\ntested false, so there's a problem!"
43
		else 
44
			puts "No Problem"			
45
		end
46
		puts 'Testing Equivalence After Converting to Strings'
47
		if ar.class.to_s != 'Array'
48
			puts ar.class
49
			puts "A problem"
50
		else 
51
			puts "No Problem"			
52
		end
53
	end	
54
end
55
puts "FIRST: Testing Within a Module: Displays the Problem and the Workaround\n = Converting to Strings"
56
puts
57
TestModule::Test.new
58
puts "SECOND: Testing Outside a Module: No problem"
59
puts
60
Test.new