perception 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_ppp.rb ADDED
@@ -0,0 +1,297 @@
1
+
2
+ require 'kyanite/unit_test'
3
+ require 'perception'
4
+
5
+
6
+ class TestPerceptionPPP < UnitTest
7
+
8
+ def setup
9
+ seee.init
10
+ seee.out = []
11
+ end
12
+
13
+
14
+ def test_010_symbol
15
+ test = :hallo_test
16
+ result1 = ":hallo_test"
17
+ result2 = "\n:hallo_test"
18
+ assert_equal result1, test.inspect_pp
19
+ assert_equal result1, test.inspect_see
20
+ assert_equal result2, see(test); setup
21
+ assert_equal result2, see_pp(test); setup
22
+ assert_equal result2, see_puts(test); setup
23
+ assert_equal result2, see_print(test); setup
24
+ end
25
+
26
+
27
+ # Bei String unterscheiden sich die Ergebnisse von inspect_see und see
28
+ def test_021_string
29
+ test = %q{Hallo "''" Welt}
30
+ result1 = %q{'Hallo "''" Welt'}
31
+ result2 = %q{Hallo "''" Welt}
32
+ result1b = %Q{\n'Hallo "''" Welt'}
33
+ result2b = %Q{\nHallo "''" Welt}
34
+
35
+ assert_equal result1, test.inspect_pp
36
+ assert_equal result1, test.inspect_see
37
+ assert_equal result1b, see_pp(test); setup
38
+
39
+ assert_equal result2b, see_puts(test); setup
40
+ assert_equal result2b, see_print(test); setup
41
+ assert_equal result2b, see(test); setup
42
+ end
43
+
44
+
45
+ def test_022_string
46
+ test = %q{}
47
+ result1 = %q{''}
48
+ result1b = %Q{\n''}
49
+ result2 = %q{empty}
50
+ result2b = %Q{\nempty}
51
+
52
+ assert_equal result1, test.inspect_pp
53
+ assert_equal result1, test.inspect_see
54
+ assert_equal result1b, see_pp(test); setup
55
+
56
+ assert_equal result2b, see_puts(test); setup
57
+ assert_equal result2b, see_print(test); setup
58
+ assert_equal result2b, see(test); setup
59
+ end
60
+
61
+
62
+ def test_031_array
63
+ test = [1,2,3]
64
+ result1 = %q{[1, 2, 3]}
65
+ result1b = %Q{\n[1, 2, 3]}
66
+ assert_equal result1, test.inspect_pp
67
+ assert_equal result1b, see_puts(test); setup
68
+ assert_equal result1b, see_print(test); setup
69
+ assert_equal result1, test.inspect_see
70
+ assert_equal result1b, see_pp(test); setup
71
+ assert_equal result1b, see(test); setup
72
+ end
73
+
74
+
75
+ def test_032_array
76
+ test = []
77
+ test << ['this','is','an','array','1']
78
+ test << ['this','is','another','array','2']
79
+ test << ['and','this','is','another', :tree]
80
+ test << ['no',{:key => :value},'just','another', 'array']
81
+ result1 = %Q{\n[['this', 'is', 'an', 'array', '1'], ['this', 'is', 'another', 'array', '2'], ['and', 'this', 'is', 'another', :tree], ['no', {:key=>:value}, 'just', 'another', 'array']]}
82
+ result2 = result1.gsub(%q{'},%q{"})
83
+ result3 = <<ENDOFSTRING
84
+ [['this', 'is', 'an', 'array', '1'],
85
+ ['this', 'is', 'another', 'array', '2'],
86
+ ['and', 'this', 'is', 'another', :tree],
87
+ ['no', {:key=>:value}, 'just', 'another', 'array']]
88
+ ENDOFSTRING
89
+ result3 = result3.chomp.strip.gsub("\n"," \n")
90
+
91
+ assert_equal result1.gsub("\n",""), test.inspect_pp
92
+ assert_equal result2, see_puts(test); setup
93
+ assert_equal result2, see_print(test); setup
94
+ assert_equal result3, test.inspect_see#.gsub("\n",'')
95
+ assert_equal "\n" + result3, see_pp(test); setup
96
+ assert_equal "\n" + result3, see(test); setup
97
+ end
98
+
99
+
100
+ def test_033_array
101
+ t1 = 'long_longlong_long_long'
102
+ t2 = 'also_long, also_long, also_long_also'
103
+ t3 = 'hallo'
104
+ test = []
105
+ test << %W{one a b c}
106
+ test << ['two', t1, t2, t3]
107
+ test << ['three', t2, t2, t1]
108
+ result1 = <<ENDOFSTRING
109
+ [['one', 'a', 'b', 'c'],
110
+ ['two', 'long_longlong_long_long', 'also_long, also_long, also_long_also', 'hallo'],
111
+ ['three', 'also_long, also_long, also_long_also', 'also_long, also_long, also_long_also', 'long_longlong_long_long']]
112
+ ENDOFSTRING
113
+ result1 = result1.chomp.strip
114
+ result2 = result1.gsub(%q{'},%q{"}).gsub("\n",'')
115
+ result3 = <<ENDOFSTRING
116
+ [['one', 'a', 'b', 'c'],
117
+ ['two', 'long_longlong_long_long', 'also_long, also_long, also_long_also', 'hallo'],
118
+ ['three', 'also_long, also_long, also_long_also', 'also_long, also_long, also_long_also', 'long_longlong_long_long']]
119
+ ENDOFSTRING
120
+ result3=result3.chomp
121
+
122
+ assert_equal result1, test.inspect_pp
123
+ assert_equal "\n" + result2, see_puts(test); setup
124
+ assert_equal "\n" + result2, see_print(test); setup
125
+ # puts
126
+ # require File.join(File.dirname(__FILE__), '..', '..', 'klippstein_ruby_extensions', 'lib', 'string' )
127
+ # pp test.inspect_see.overlapdiff(result3)
128
+ # puts
129
+ assert_equal result3, test.inspect_see#.gsub("\n",'')
130
+ assert_equal "\n" + result3, see_pp(test); setup
131
+ assert_equal "\n" + result3, see(test); setup
132
+
133
+ end
134
+
135
+
136
+
137
+ def test_040_object
138
+ seee.logger
139
+ see 'hi'
140
+ seee.time_last = Time.at(1296702800)
141
+ test = seee
142
+ result1 = <<ENDOFSTRING
143
+ #<Perception::SeeSession:0x2860d24
144
+ @call_stack_last = 20,
145
+ @call_stack_now = 20,
146
+ @cursor_now = 0,
147
+ @delayed_clear = false,
148
+ @delayed_newlines = 0,
149
+ @indent = false,
150
+ @level = 1,
151
+ @logger = #<Logger:0x2ae165c @default_formatter=#<>, @formatter=nil, @level=0, @logdev=#<<><[][]>>, @progname=nil>,
152
+ @method_last = :puts,
153
+ @method_now = :pp,
154
+ @out = [],
155
+ @speed = nil,
156
+ @string_last = 'hi',
157
+ @time_last = 2011-02-03 Thursday 04:13:20>
158
+ ENDOFSTRING
159
+ result1 = result1.strip.chomp.gsub("\n",' ')
160
+
161
+ # seee-ID austauschen
162
+ id = "%x" % (seee.__id__ * 2)
163
+ id.sub!(/\Af(?=[[:xdigit:]]{2}+\z)/, '') if id.sub!(/\A\.\./, '')
164
+ id = "0x#{id}"
165
+ result1 = result1.gsub('0x2860d24',id)
166
+
167
+ # Logger-ID austauschen
168
+ id = "%x" % (seee.logger.__id__ * 2)
169
+ id.sub!(/\Af(?=[[:xdigit:]]{2}+\z)/, '') if id.sub!(/\A\.\./, '')
170
+ id = "0x#{id}"
171
+ result1 = result1.gsub('0x2ae165c',id)
172
+
173
+ assert_equal result1, see(test).strip.chomp.gsub("\n",' '); setup
174
+ end
175
+
176
+
177
+
178
+ def test_053_dictionary
179
+ require 'facets/dictionary'
180
+
181
+ @dictionary = Dictionary.new
182
+ @dictionary[:a_dictionary] = true
183
+ @dictionary[:b_init] = true
184
+ @dictionary[:c_symbol] = :symbol
185
+ @dictionary[:d_array] = [1,2,3]
186
+ @dictionary[:e_integer] = 1
187
+ @dictionary[:f_string] = 'hallo'
188
+ @subdictionary = Dictionary.new
189
+ @subdictionary[:a] = :value
190
+ @subdictionary[:b] = 'blubb'
191
+ @subdictionary[:c] = 2
192
+ @subdictionary[:d] = [:a,:b,:c]
193
+ @subdictionary[:e] = { :key => :value}
194
+ @subdictionary[:f] = 'hallo'
195
+ @dictionary[:g_subdictionary] = @subdictionary
196
+ test = @dictionary
197
+
198
+ result1 = <<ENDOFSTRING
199
+ {:a_dictionary=>true,
200
+ :b_init=>true,
201
+ :c_symbol=>:symbol,
202
+ :d_array=>[1, 2, 3],
203
+ :e_integer=>1,
204
+ :f_string=>'hallo',
205
+ :g_subdictionary=>
206
+ {:a=>:value,
207
+ :b=>'blubb',
208
+ :c=>2,
209
+ :d=>[:a, :b, :c],
210
+ :e=>{:key=>:value},
211
+ :f=>'hallo'}}
212
+ ENDOFSTRING
213
+ result1 = result1.chomp
214
+ result2 = '{:a_dictionary=>true, :b_init=>true, :c_symbol=>:symbol, :d_array=>[1, 2, 3], :e_integer=>1, :f_string=>"hallo", :g_subdictionary=>{:a=>:value, :b=>"blubb", :c=>2, :d=>[:a, :b, :c], :e=>{:key=>:value}, :f=>"hallo"}}'
215
+ result3 = <<ENDOFSTRING
216
+ {:a_dictionary => true,
217
+ :b_init => true,
218
+ :c_symbol => :symbol,
219
+ :d_array => [1, 2, 3],
220
+ :e_integer => 1,
221
+ :f_string => 'hallo',
222
+ :g_subdictionary => {:a=>:value, :b=>'blubb', :c=>2, :d=>[:a, :b, :c], :e=>{:key=>:value}, :f=>'hallo'}}
223
+ ENDOFSTRING
224
+ result3 = result3.chomp
225
+
226
+
227
+ assert_equal result1, test.inspect_pp
228
+ assert_equal "\n" + result2, see_puts(test); setup
229
+ assert_equal "\n" + result2, see_print(test); setup
230
+
231
+ assert_equal result3, test.inspect_see
232
+ assert_equal "\n" + result3, see_pp(test); setup
233
+ assert_equal "\n" + result3, see(test); setup
234
+ end
235
+
236
+
237
+ def test_061_set
238
+ test = SortedSet.new([1,2,3])
239
+ result1 = "{1, 2, 3}"
240
+ assert_equal result1, test.inspect_pp
241
+ assert_equal result1, test.inspect_see
242
+ assert_equal "\n" + result1, see_puts(test); setup
243
+ assert_equal "\n" + result1, see_print(test); setup
244
+ assert_equal "\n" + result1, see_pp(test); setup
245
+ assert_equal "\n" + result1, see(test); setup
246
+ end
247
+
248
+
249
+ def test_071_multi
250
+ result = see 'hallo', '1'
251
+ assert_equal %Q{\n'hallo' '1'}, result
252
+ setup
253
+
254
+ result = see 'halloewtewgsdgvsdgdfgbdfxbgdgbdfgdfxgdsf', '1'
255
+ assert_equal %Q{\n'halloewtewgsdgvsdgdfgbdfxbgdgbdfgdfxgdsf' '1'}, result
256
+ setup
257
+
258
+ result = see :a, '1'
259
+ assert_equal %Q{\n:a '1'}, result
260
+ setup
261
+
262
+ result = see [:a,:b], '1'
263
+ assert_equal %Q{\n[:a, :b] '1'}, result
264
+ setup
265
+
266
+ result = see [1,2], [:a,:b]
267
+ assert_equal %Q{\n[1, 2] [:a, :b]}, result
268
+ setup
269
+
270
+ result = see :a,:b,:c
271
+ assert_equal %Q{\n:a :b :c}, result
272
+ setup
273
+
274
+ result = see 1,2,3
275
+ assert_equal %Q{\n1 2 3}, result
276
+ setup
277
+ end
278
+
279
+
280
+ end # class
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
4
+ <title>perception</title>
5
+
6
+ </head>
7
+ <body id="body">
8
+ <p>This page has not yet been created for RubyGem <code>perception</code></p>
9
+ <p>To the developer: To generate it, update website/index.txt and run the rake task <code>website</code> to generate this <code>index.html</code> file.</p>
10
+ </body>
11
+ </html>
data/website/index.txt ADDED
@@ -0,0 +1,83 @@
1
+ h1. perception
2
+
3
+ h1. &#x2192; 'perception'
4
+
5
+
6
+ h2. What
7
+
8
+
9
+ h2. Installing
10
+
11
+ <pre syntax="ruby">sudo gem install perception</pre>
12
+
13
+ h2. The basics
14
+
15
+
16
+ h2. Demonstration of usage
17
+
18
+
19
+
20
+ h2. Forum
21
+
22
+ "http://groups.google.com/group/perception":http://groups.google.com/group/perception
23
+
24
+ TODO - create Google Group - perception
25
+
26
+ h2. How to submit patches
27
+
28
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
29
+
30
+ TODO - pick SVN or Git instructions
31
+
32
+ The trunk repository is <code>svn://rubyforge.org/var/svn/perception/trunk</code> for anonymous access.
33
+
34
+ OOOORRRR
35
+
36
+ You can fetch the source from either:
37
+
38
+ <% if rubyforge_project_id %>
39
+
40
+ * rubyforge: "http://rubyforge.org/scm/?group_id=<%= rubyforge_project_id %>":http://rubyforge.org/scm/?group_id=<%= rubyforge_project_id %>
41
+
42
+ <pre>git clone git://rubyforge.org/perception.git</pre>
43
+
44
+ <% else %>
45
+
46
+ * rubyforge: MISSING IN ACTION
47
+
48
+ TODO - You can not created a RubyForge project, OR have not run <code>rubyforge config</code>
49
+ yet to refresh your local rubyforge data with this projects' id information.
50
+
51
+ When you do this, this message will magically disappear!
52
+
53
+ Or you can hack website/index.txt and make it all go away!!
54
+
55
+ <% end %>
56
+
57
+ * github: "http://github.com/GITHUB_USERNAME/perception/tree/master":http://github.com/GITHUB_USERNAME/perception/tree/master
58
+
59
+ <pre>git clone git://github.com/GITHUB_USERNAME/perception.git</pre>
60
+
61
+
62
+ TODO - add "github_username: username" to ~/.rubyforge/user-config.yml and newgem will reuse it for future projects.
63
+
64
+
65
+ * gitorious: "git://gitorious.org/perception/mainline.git":git://gitorious.org/perception/mainline.git
66
+
67
+ <pre>git clone git://gitorious.org/perception/mainline.git</pre>
68
+
69
+ h3. Build and test instructions
70
+
71
+ <pre>cd perception
72
+ rake test
73
+ rake install_gem</pre>
74
+
75
+
76
+ h2. License
77
+
78
+ This code is free to use under the terms of the MIT license.
79
+
80
+ h2. Contact
81
+
82
+ Comments are welcome. Send an email to "Bjoern Klippstein":mailto:FIXME email via the "forum":http://groups.google.com/group/perception
83
+