S
Simon Strandgaard
When doing unittesting I ofthen need to compare some computed data against
what is expected. I have a class hierarchy derived from a base class.
How do one install a compare method in the base class, which ignores 'id' ?
--
Simon Strandgaard
def test_transform
a = mk_letter 'a'
b = mk_letter 'b'
alt = mk_alternation(a, b)
wild = mk_wild
c = mk_letter 'c'
rep = mk_repeat wild, 0, 1
seq = mk_sequence alt, rep, c
s = ScannerHierarchy
exp = [
s::Alternation.new(true),
s:attern.new(true),
s::Match.new(a),
s:attern.new(false),
s:attern.new(true),
s::Match.new(b),
s:attern.new(false),
s::Alternation.new(false),
s::Repeat.new(true),
s::Match.new(wild),
s::Repeat.new(false),
s::Match.new(c)
]
v = TransformVisitor.new
seq.accept(v)
assert_equal(exp, v.result)
end
what is expected. I have a class hierarchy derived from a base class.
How do one install a compare method in the base class, which ignores 'id' ?
--
Simon Strandgaard
def test_transform
a = mk_letter 'a'
b = mk_letter 'b'
alt = mk_alternation(a, b)
wild = mk_wild
c = mk_letter 'c'
rep = mk_repeat wild, 0, 1
seq = mk_sequence alt, rep, c
s = ScannerHierarchy
exp = [
s::Alternation.new(true),
s:attern.new(true),
s::Match.new(a),
s:attern.new(false),
s:attern.new(true),
s::Match.new(b),
s:attern.new(false),
s::Alternation.new(false),
s::Repeat.new(true),
s::Match.new(wild),
s::Repeat.new(false),
s::Match.new(c)
]
v = TransformVisitor.new
seq.accept(v)
assert_equal(exp, v.result)
end