Ticket #280 (closed defect: invalid)
'or require' and 'and ensure' not working as expected on overriden method
Reported by: | cmitchell | Owned by: | Charles |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | Cc: |
Description
Given the following Cobra code:
@args -t:lib namespace CobraLib class Person pro firstName from var = '' pro lastName from var = '' def speak() as String return 'My name is [.firstName] [.lastName]' class Speaker inherits Person def speak() as String is override or require .firstName is not '' .lastName is not '' and ensure result.startsWith('My name is') body return 'My name is not what you think it is'
When I compile it and reference it in a c# console app like this:
using System; using CobraLib; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var p = new Speaker(); Console.WriteLine(p.Speak()); Console.ReadLine(); } } }
My expectation is that the code contracts will cause a runtime exception. However, the code executes without issue.
Likewise, when I add the code contracts to the Person class and use that class in the c# code, the code contracts cause an exception as expected.
Change History
Note: See
TracTickets for help on using
tickets.