Wiki

Ticket #293 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

test blocks in generic classes ignored

Reported by: jaegs Owned by: Charles
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: generic test Cc:

Description

Testing the following code

class X<of T>
  test
    assert false

with

cobra -test foo.cobra

results in 0 failures.

Change History

Changed 12 years ago by Charles

Coming soon.

Changed 12 years ago by Charles

  • owner set to Charles
  • status changed from new to assigned

Changed 12 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in changeset:2839

Changed 12 years ago by Charles

Note the following:

  • Cobra creates shared/static methods for each test block.
  • In C# (and probably .NET in general for that matter), shared methods cannot be invoked on generic method defs such as Foo<of T>. Instead the generic type must be instantiated such as Foo<of int>.
  • Due to possibilities like generic type constraints and classes whose initializers require arguments, it is not trivial to instantiate an arbitrary generic type.
  • To account for this, the test blocks in a generic type are now placed in a non-generic helper class named after the original type.
  • Consequently, the test blocks cannot access the shared methods of the original type--other than instantiating the original type with concrete type args, in order to do so.
Note: See TracTickets for help on using tickets.