home recent topics recent posts search faq  

Pretty Objects Visual T# Forum

Addicted toThe Most Intelligent Add-In To Visual Studio Addicted toAddicted to


register | lost password   open id sign in with Twitter
Messages in this topic - RSS

Home » T# Compiler » Combining criteria with OR

Conversations on T# compiler features, usability, wish list...
20/05/2010 11:03:37 AM

Arsène von Wyss
Arsène von Wyss
Posts: 8
I have been trying to implement a test which uses the || criteria operator, closely following the following sample in the documentation:

testclass for Product {
test Price set
when MinIncluded.BelowMinCase
{
... // code testing negative price
}

test Price set
{
runtest ValidatePriceSet( 0 );
runtest ValidatePriceSet( 10 );
}

test Price set
signature ValidatePriceSet( double val )
when MinIncluded.IsMin || MinIncluded.IsAboveMin
{
Product p = new Product( "T#", 100 );
runtest p.Price = val;
assert p.Price == val;
}
}



One minor issue was that the signature which requires a "void" before the method name. That was quickly fixed.




However, now the tests still fail, I get a NullReferenceException which I have no idea what causes it. The test output is not helpful in locating the error and the debugger doesn't give me more information either; the following is in the output:





A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll

A first chance exception of type 'System.NullReferenceException' occurred in TSharp.dll

A first chance exception of type 'System.NullReferenceException' occurred in TSharp.dll

A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll




Here's my test code:



using System;
using System.IO;
using TSharp.Criteria;
using bsn.GoldParser.Grammar;

namespace bsn.GoldParserTest {
testclass for CompiledGrammar {
private CompiledGrammar grammar;

testcontext {
using (Stream stream = new FileStream(@"Z:\Test\TestGrammar.cgt", FileMode.Open)) {
grammar = CompiledGrammar.Load(stream);
}
runtest;
}

test TryGetSymbol(string symbolName, out Symbol)
when symbolName: ValidFormattedString.NullCase {
Symbol symbol;
bool result;
runtest result = grammar.TryGetSymbol(null, out symbol);
assert thrown ArgumentNullException;
}

test TryGetSymbol(string symbolName, out Symbol)
signature void ValidateTryGetSymbol(string symName)
when symbolName: ValidFormattedString.EmptyCase || ValidFormattedString.InvalidFormatCase {
Symbol symbol;
bool result;
runtest result = grammar.TryGetSymbol(symName, out symbol);
assert result == false;
assert symbol == null;
}

test TryGetSymbol(string symbolName, out Symbol) {
runtest ValidateTryGetSymbol(null);
runtest ValidateTryGetSymbol("invalid name");
}

test TryGetSymbol(string symbolName, out Symbol)
when symbolName: ValidFormattedString.IsValidFormat {
Symbol symbol;
bool result;
runtest result = grammar.TryGetSymbol("Integer", out symbol);
assert result == true;
assert symbol.Name == "Integer";
}
}
}

0 permalink
25/05/2010 9:46:06 AM

Ludovic Dubois
Ludovic Dubois
Administrator
Posts: 155
See discussion at: TSHARP-147 smile
0 permalink

Home » T# Compiler » Combining criteria with OR





Powered by Jitbit Forum 7.2.7.0 © 2006-2011 Jitbit Software