sequence 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +58 -0
- data/GPL +340 -0
- data/Manifest.txt +36 -0
- data/README.txt +320 -0
- data/Rakefile +32 -0
- data/lib/assert.rb +16 -0
- data/lib/sequence/arraylike.rb +57 -0
- data/lib/sequence/buffered.rb +188 -0
- data/lib/sequence/circular.rb +272 -0
- data/lib/sequence/enum.rb +260 -0
- data/lib/sequence/file.rb +172 -0
- data/lib/sequence/functional.rb +152 -0
- data/lib/sequence/generator.rb +290 -0
- data/lib/sequence/indexed.rb +234 -0
- data/lib/sequence/io.rb +102 -0
- data/lib/sequence/list.rb +292 -0
- data/lib/sequence/ofhash.rb +38 -0
- data/lib/sequence/ofobjectivars.rb +29 -0
- data/lib/sequence/ofobjectmethods.rb +87 -0
- data/lib/sequence/position.rb +100 -0
- data/lib/sequence/reversed.rb +180 -0
- data/lib/sequence/shifting.rb +190 -0
- data/lib/sequence/singleitem.rb +50 -0
- data/lib/sequence/stringlike.rb +482 -0
- data/lib/sequence/subseq.rb +90 -0
- data/lib/sequence/usedata.rb +35 -0
- data/lib/sequence/version.rb +5 -0
- data/lib/sequence.rb +721 -0
- data/lib/weakrefset.rb +254 -0
- data/test/test.rb +609 -0
- data/test/test_all.rb +6 -0
- data/test/test_changes.rb +44 -0
- data/test/test_circulars.rb +89 -0
- data/test/test_rexscan.rb +899 -0
- data/test/test_seqrex.rb +204 -0
- data/test/test_sequences.rb +106 -0
- metadata +90 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
#eric's original test code; I can't say I understand it
|
2
|
+
BEGIN{exit}
|
3
|
+
#!/bin/env ruby
|
4
|
+
#
|
5
|
+
# $Id$
|
6
|
+
#
|
7
|
+
# Run this to test circular sequences.
|
8
|
+
# Here is a list of the optional arguments:
|
9
|
+
#
|
10
|
+
# <iterations> : approximate number of times to test each method
|
11
|
+
# <seed> : seed for random number generation (0: none)
|
12
|
+
# <classRE> : regular expression for the classes to test ('': all)
|
13
|
+
# <methodRE> : regular expression for the methods to test ('': all)
|
14
|
+
# <flags> : Combination of bits for various flags
|
15
|
+
# 1 : disable testing of positions
|
16
|
+
# 2 : only test with strings/characters
|
17
|
+
#
|
18
|
+
# All of the standar Test::Unit auto runner options apply. The --verbose=<level>
|
19
|
+
# option is especially useful. Here are the various levels:
|
20
|
+
#
|
21
|
+
# s[ilent] : don't display anything
|
22
|
+
# p[rogress] : show a progress bar. Upon fail, show the test and seed.
|
23
|
+
# n[ormal] : show each method (and args) tested
|
24
|
+
# v[erbose] : show each method and the object state (inspect)
|
25
|
+
#
|
26
|
+
# If you want to see a demo for a particular method, usually a good command
|
27
|
+
# line would be something like this:
|
28
|
+
#
|
29
|
+
# ruby sequence/test_circulars.rb --verbose=v 10 0 Indexed '^(<method>|close)$'
|
30
|
+
|
31
|
+
require 'sequence/test'
|
32
|
+
require 'sequence/circular'
|
33
|
+
require 'sequence/indexed'
|
34
|
+
require 'sequence/circular/indexed'
|
35
|
+
require 'sequence/circular/shifting'
|
36
|
+
require 'sequence/circular/split'
|
37
|
+
require 'sequence/circular/linked'
|
38
|
+
|
39
|
+
# :stopdoc:
|
40
|
+
|
41
|
+
class Sequence
|
42
|
+
class Test
|
43
|
+
class Circulars < Test
|
44
|
+
def self.suite
|
45
|
+
@reject = /^(scan_until|modify|each|collect!|map!|scan_pattern_(while|until))$/
|
46
|
+
$0==__FILE__ ? super(*ARGV) : super()
|
47
|
+
end
|
48
|
+
def self.seed(before,after)
|
49
|
+
sequences = [
|
50
|
+
Sequence::Circular::Indexed.new(before+after,before.size),
|
51
|
+
Sequence::Circular::Indexed.new(after+before,0),
|
52
|
+
Sequence::Circular::Shifting.new(after+before,after.size),
|
53
|
+
Sequence::Circular::Split.new(before.clone,after.reverse),
|
54
|
+
Sequence::Circular::Linked.new(before.clone,after.reverse),
|
55
|
+
Sequence::Circular.new(Sequence::Indexed.new(before+after,before.size)),
|
56
|
+
]
|
57
|
+
if rand(2).zero?
|
58
|
+
@use_positions = false
|
59
|
+
sequences << Sequence::Circular.new(
|
60
|
+
Sequence::Indexed.new(before+after,before.size)
|
61
|
+
).position
|
62
|
+
else
|
63
|
+
@use_positions = @flags[0].zero?
|
64
|
+
end
|
65
|
+
sequences
|
66
|
+
end
|
67
|
+
def self.plant
|
68
|
+
@characters = @flags[1].nonzero?||rand(2).zero?
|
69
|
+
super
|
70
|
+
end
|
71
|
+
def self.elements
|
72
|
+
@flags[1].nonzero? ? [?A,?B,?C] : @characters ? [?\n,?\0,?0] : [false,"",[]]
|
73
|
+
end
|
74
|
+
def self.empty
|
75
|
+
@characters&&(@flags[1].nonzero?||rand(2).zero?) ? "" : []
|
76
|
+
end
|
77
|
+
def self.reject(name,*args,&block)
|
78
|
+
case name
|
79
|
+
when :position! then !@use_positions && args[0].nil?
|
80
|
+
when :position? then !@use_positions && args[0].nil? && block.nil?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# :startdoc:
|
88
|
+
|
89
|
+
|