Browse files

use fixture suffix only for interpreter type matching

  • Loading branch information...
1 parent b0ad24f commit 5b4c934ff431fcff9e1474c4a88b680d095cf7e1 @jediwhale committed Mar 19, 2012
Showing with 164 additions and 204 deletions.
  1. +1 −1 document/fitSharp/Fit/GracefulNames.html
  2. +2 −2 document/fitSharp/Fit/PlainTextFormat.html
  3. +2 −2 document/fitSharp/Fit/WithKeyword.html
  4. +1 −1 document/fitSharp/FitLibraryTests/ArrayFixture/TestNestedArray.html
  5. +1 −1 document/fitSharp/FitLibraryTests/DoFixture/TestBadAction.html
  6. +1 −1 document/fitSharp/FitLibraryTests/DoFixture/TestUnexpectedException.html
  7. +0 −12 source/fit/Exception/FitFailureException.cs
  8. +2 −2 source/fit/Fixtures/ActionFixture.cs
  9. +1 −1 source/fit/Fixtures/SetUpFixture.cs
  10. +0 −51 source/fit/Fixtures/UseFixture.cs
  11. +1 −1 source/fit/Model/CellRange.cs
  12. +1 −1 source/fit/Model/ParseTable.cs
  13. +1 −0 source/fit/Operators/NamedMatchStrategy.cs
  14. +0 −2 source/fit/fit.csproj
  15. +1 −4 source/fitSharp/Fit/Engine/MethodPhrase.cs
  16. +12 −0 source/fitSharp/Fit/Exception/FitFailureException.cs
  17. +44 −0 source/fitSharp/Fit/Fixtures/UseFixture.cs
  18. +1 −1 source/fitSharp/Fit/Operators/CellOperators.cs
  19. +4 −2 source/fitSharp/Fit/Operators/ParseInterpreter.cs
  20. +0 −39 source/fitSharp/Fit/Operators/ParseType.cs
  21. +3 −3 source/fitSharp/Machine/Engine/CreateDefault.cs
  22. +2 −2 source/fitSharp/Machine/Engine/Operator.cs
  23. +6 −4 source/fitSharp/Machine/Engine/ParseType.cs
  24. +17 −4 source/fitSharp/Machine/Engine/Processor.cs
  25. +27 −0 source/fitSharp/Machine/Model/GracefulNameMatcher.cs
  26. +0 −30 source/fitSharp/Machine/Model/LanguageName.cs
  27. +9 −4 source/fitSharp/Slim/Operators/ExecuteMake.cs
  28. +3 −2 source/fitSharp/fitSharp.csproj
  29. +2 −2 source/fitSharpTest/NUnit/Machine/CreateDefaultTest.cs
  30. +0 −19 source/fitSharpTest/NUnit/Machine/LanguageNameTest.cs
  31. +3 −3 source/fitSharpTest/NUnit/Machine/OperatorsTest.cs
  32. +0 −1 source/fitSharpTest/fitSharpTest.csproj
  33. +1 −1 source/fitTest/Acceptance/SpecifyFixture.cs
  34. +1 −1 source/fitTest/Acceptance/SystemUnderTest.cs
  35. +12 −3 source/fitTest/Acceptance/TypeName.cs
  36. +1 −1 source/fitTest/NUnit/CellMatching.cs
  37. +1 −0 storytest.config.xml
View
2 document/fitSharp/Fit/GracefulNames.html
@@ -59,7 +59,7 @@
<tr><td>ArithmeticColumn</td><td>eg.ArithmeticColumnFixture</td></tr>
<tr><td> Arithmetic Column </td><td>eg.ArithmeticColumnFixture</td></tr>
<tr><td>arithmetic column</td><td>eg.ArithmeticColumnFixture</td></tr>
-<tr><td>arith-metic!...@column?</td><td>eg.ArithmeticColumnFixture</td></tr>
+<tr><td>arith-metic!%^$@column?</td><td>eg.ArithmeticColumnFixture</td></tr>
<tr><td>another sample domain</td><td>fit.Test.Double.another_sample_domain</td></tr>
</table>
<br>
View
4 document/fitSharp/Fit/PlainTextFormat.html
@@ -20,14 +20,14 @@
<br>
The test is organized into tables, the same as traditional HTML table tests. Each table row is written as one line of text. The table cells are separated by white space. If a cell contains embedded white space, we can wrap the cell content in quotes. The tables are separated by blank lines. Here's a simple test: <pre class="test">test&#64;
-with new fitSharp.Samples.Person Bob Marley
+with new person Bob Marley
check 'first name' Bob
check 'last name' Marley
&#64;test</pre> This is the result when we run it: <pre class="test">test@
-with new fitSharp.Samples.Person Bob Marley
+with new person Bob Marley
check 'first name' Bob
check 'last name' Marley
View
4 document/fitSharp/Fit/WithKeyword.html
@@ -83,14 +83,14 @@
</td><td><br><table border="1" cellpadding="2" cellspacing="0"><tr><td>do</td></tr><tr><td>with</td><td>new</td><td>sample domain</td><td>Joe</td></tr><tr><td>name</td><td class="pass">joesname</td><td>name</td></tr><tr><td>with</td><td>joesname</td></tr><tr><td>check</td><td>tolower</td><td class="pass">joe</td></tr></table></td></tr>
</table>
<br>
-For named objects or methods, the enclosing fixture must be a flow fixture.<br>
+The enclosing fixture must provide a method.<br>
<br>
<table border="1" cellpadding="2" cellspacing="0">
<tr><td>check</td><td>test result</td><td><br>
<table border="1" cellpadding="2" cellspacing="0">
<tr><td>use</td><td>column</td><td>with</td><td>my method</td></tr>
</table>
-</td><td><br><table border="1" cellpadding="2" cellspacing="0"><tr><td class="error">use<hr /><pre><div class="fit_stacktrace">This table is invalid for this fixture: flow fixture required for with.</div></pre></td><td>column</td><td>with</td><td>my method</td></tr></table></td></tr>
+</td><td><br><table border="1" cellpadding="2" cellspacing="0"><tr><td class="error">use<hr /><pre><div class="fit_stacktrace">Member 'mymethod' with 0 parameter(s) not found</div></pre></td><td>column</td><td>with</td><td>my method</td></tr></table></td></tr>
</table>
<br>
Errors are reported if information is missing.<br>
View
2 document/fitSharp/FitLibraryTests/ArrayFixture/TestNestedArray.html
@@ -75,7 +75,7 @@
<tr><td colspan="2"><i>nested</i></td></tr>
<tr><td><i>name</i></td><td><i>elements</i></td></tr>
<tr><td class="pass">apple</td><td><table border="1" cellspacing="0">
-<tr><td class="error"><i>identity</i><hr /><pre><div class="fit_stacktrace">fitlibrary.exception.FitFailureException: Column 'identity' not used.</div></pre></td><td><i>count</i></td></tr>
+<tr><td class="error"><i>identity</i><hr /><pre><div class="fit_stacktrace">Column 'identity' not used.</div></pre></td><td><i>count</i></td></tr>
<tr><td class="fail">a <span class="fit_label">expected</span><hr />void <span class="fit_label">actual</span></td><td class="pass">1</td></tr>
<tr class="fail">
<td><span class="fit_grey"></span> <span class="fit_label">surplus</span></td>
View
2 document/fitSharp/FitLibraryTests/DoFixture/TestBadAction.html
@@ -16,7 +16,7 @@
<tr><td><table border><tr><td>DoFixtureFlowUnderTest</td></tr>
</table>
<table border>
-<tr><td class="error">not known<hr /> <span class="fit_stacktrace">Type 'not known' not found in assemblies</span></td><td colspan=2>1</td></tr></table>
+<tr><td class="error">not known<hr /> <span class="fit_stacktrace">Type 'notknown' not found in assemblies</span></td><td colspan=2>1</td></tr></table>
<table border><tr><td>check</td><td class="error">not known<hr /> <span class="fit_stacktrace">Member 'notknown' with 0 parameter(s) not found for type 'fit.Test.Acceptance.DoFixtureFlowUnderTest'.
</span></td><td>3</td></tr>
</table></td>
View
2 document/fitSharp/FitLibraryTests/DoFixture/TestUnexpectedException.html
@@ -15,7 +15,7 @@
<tr><td><table border><tr><td>DoFixtureFlowUnderTest</td></tr>
</table>
<table border>
-<tr><td class="error">exception action<hr /> <span class="fit_stacktrace">Type 'exception action' not found in assemblies</span></td></tr>
+<tr><td class="error">exception action<hr /> <span class="fit_stacktrace">Type 'exceptionaction' not found in assemblies</span></td></tr>
</table></td>
</tr>
</table>
View
12 source/fit/Exception/FitFailureException.cs
@@ -1,12 +0,0 @@
-// Copyright © 2009 Syterra Software Inc. Includes work © 2003-2006 Rick Mugridge, University of Auckland, New Zealand.
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-
-namespace fitlibrary.exception {
- public class FitFailureException: ApplicationException {
- public FitFailureException(string theMessage): base(theMessage) {}
- }
-}
View
4 source/fit/Fixtures/ActionFixture.cs
@@ -1,4 +1,4 @@
-// Copyright © 2011 Syterra Software Inc. Includes work by Object Mentor, Inc., © 2002 Cunningham & Cunningham, Inc.
+// Copyright © 2012 Syterra Software Inc. Includes work by Object Mentor, Inc., © 2002 Cunningham & Cunningham, Inc.
// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
@@ -38,7 +38,7 @@ public override void DoCells(Parse cells)
public virtual void Start()
{
- actor = Processor.Create(cells.More.Text.Trim()).Value;
+ actor = Processor.Create(cells.More).Value;
var fixture = actor as Fixture;
if (fixture != null) fixture.Processor = Processor;
}
View
2 source/fit/Fixtures/SetUpFixture.cs
@@ -6,8 +6,8 @@
using fit;
using System;
using fit.Model;
-using fitlibrary.exception;
using fitSharp.Fit.Engine;
+using fitSharp.Fit.Exception;
using fitSharp.Machine.Exception;
namespace fitlibrary {
View
51 source/fit/Fixtures/UseFixture.cs
@@ -1,51 +0,0 @@
-// Copyright © 2011 Syterra Software Inc.
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using fit.Model;
-using fitlibrary;
-using fitlibrary.exception;
-using fitSharp.Fit.Engine;
-using fitSharp.Fit.Exception;
-using fitSharp.Machine.Engine;
-using fitSharp.Machine.Model;
-
-namespace fit {
- public class UseFixture: Fixture {
-
- public override void DoTable(Parse theTable) {
- Parse firstRowCells = theTable.Parts.Parts;
- Parse restOfTheCells = firstRowCells.More;
- if (restOfTheCells == null) throw new TableStructureException("Missing cells for use.");
-
- string fixtureName = restOfTheCells.Text;
- var targetFixture = GetNamedFixture(fixtureName) ?? MakeNewFixture(fixtureName, restOfTheCells.More);
-
- targetFixture.Interpret(Processor, theTable);
- }
-
- Interpreter GetNamedFixture(string theName) {
- if (!Symbols.HasValue(theName)) return null;
-
- var result = Processor.Operate<WrapOperator>(new TypedValue(Symbols.GetValue(theName)));
- result.AsNot<Interpreter>(() => { throw new FitFailureException("Result is not a Fixture."); });
- return result.GetValueAs<Interpreter>();
- }
-
- Interpreter MakeNewFixture(string theFixtureName, Parse theRestOfTheCells) {
- var fixture = Processor.Create(theFixtureName.Trim()).Value as Interpreter; //todo: parse interpreter?
- if (fixture == null) {
- throw new FitFailureException(theFixtureName + " is not a Fixture.");
- }
- if (theRestOfTheCells != null) {
- var adapter = fixture as MutableDomainAdapter;
- if (adapter != null) {
- Fixture parent = Processor.CallStack.DomainAdapter.GetValueAs<FlowFixtureBase>();
- adapter.SetSystemUnderTest(new MethodPhrase(new CellRange(theRestOfTheCells)).Evaluate(parent ?? this, Processor));
- }
- }
- return fixture;
- }
- }
-}
View
2 source/fit/Model/CellRange.cs
@@ -5,7 +5,7 @@
using System;
using System.Collections.Generic;
-using fitlibrary.exception;
+using fitSharp.Fit.Exception;
using fitSharp.Machine.Model;
namespace fit.Model {
View
2 source/fit/Model/ParseTable.cs
@@ -3,7 +3,7 @@
// Based on designs from Fit (c) 2002 Cunningham & Cunningham, Inc., FitNesse by Object Mentor Inc., FitLibrary (c) 2003-2006 Rick Mugridge, University of Auckland, New Zealand.
using fit;
-using fitlibrary.exception;
+using fitSharp.Fit.Exception;
namespace fitlibrary.table {
View
1 source/fit/Operators/NamedMatchStrategy.cs
@@ -6,6 +6,7 @@
using System;
using fitlibrary.exception;
using fitSharp.Fit.Engine;
+using fitSharp.Fit.Exception;
using fitSharp.Fit.Model;
using fitSharp.Machine.Model;
View
2 source/fit/fit.csproj
@@ -59,7 +59,6 @@
<Compile Include="Runner\SuiteRunner.cs" />
<Compile Include="Service\Operators.cs" />
<Compile Include="Service\Service.cs" />
- <Compile Include="Exception\FitFailureException.cs" />
<Compile Include="Exception\RowWidthException.cs" />
<Compile Include="Fixtures\ActionFixture.cs" />
<Compile Include="Fixtures\ArrayFixture.cs" />
@@ -82,7 +81,6 @@
<Compile Include="Fixtures\SummaryFixture.cs" />
<Compile Include="Fixtures\TableFixture.cs" />
<Compile Include="Fixtures\UnnamedCollectionFixtureBase.cs" />
- <Compile Include="Fixtures\UseFixture.cs" />
<Compile Include="Fixtures\XmlFixture.cs" />
<Compile Include="Model\ParseTable.cs" />
<Compile Include="Model\ScientificDouble.cs" />
View
5 source/fitSharp/Fit/Engine/MethodPhrase.cs
@@ -43,10 +43,7 @@ public class MethodPhrase {
public object EvaluateNew(CellProcessor processor) {
if (cells.Branches.Count < 2) throw MakeException("missing cells");
- return processor.Create(
- cells.ValueAt(1).Text,
- cells.Skip(2))
- .Value;
+ return processor.Create(cells.Branches[1], cells.Skip(2)).Value;
}
static readonly IdentifierName newIdentifier = new IdentifierName("new");
View
12 source/fitSharp/Fit/Exception/FitFailureException.cs
@@ -0,0 +1,12 @@
+// Copyright © 2012 Syterra Software Inc. All rights reserved.
+// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
+// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
+
+using System;
+
+namespace fitSharp.Fit.Exception {
+ public class FitFailureException: ApplicationException {
+ public FitFailureException(string theMessage): base(theMessage) {}
+ }
+}
View
44 source/fitSharp/Fit/Fixtures/UseFixture.cs
@@ -0,0 +1,44 @@
+// Copyright © 2012 Syterra Software Inc. All rights reserved.
+// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
+// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
+
+using fitSharp.Fit.Engine;
+using fitSharp.Fit.Exception;
+using fitSharp.Machine.Engine;
+using fitSharp.Machine.Model;
+
+namespace fitSharp.Fit.Fixtures {
+ public class UseFixture: Interpreter {
+ public void Interpret(CellProcessor processor, Tree<Cell> table) {
+ var firstRow = table.Branches[0];
+ if (firstRow.Branches.Count < 2) throw new TableStructureException("Missing cells for use.");
+
+ var fixtureName = firstRow.ValueAt(1).Text;
+ var targetFixture = GetNamedFixture(processor, fixtureName)
+ ?? MakeNewFixture(processor, firstRow);
+
+ targetFixture.Interpret(processor, table);
+ }
+
+ static Interpreter GetNamedFixture(CellProcessor processor, string theName) {
+ if (!processor.Get<Symbols>().HasValue(theName)) return null;
+
+ var result = processor.Operate<WrapOperator>(new TypedValue(processor.Get<Symbols>().GetValue(theName)));
+ result.AsNot<Interpreter>(() => { throw new FitFailureException("Result is not a Fixture."); });
+ return result.GetValueAs<Interpreter>();
+ }
+
+ static Interpreter MakeNewFixture(CellProcessor processor, Tree<Cell> firstRow) {
+ var fixture = processor.ParseTree<Cell, Interpreter>(firstRow.Skip(1));
+ if (firstRow.Branches.Count > 2) {
+ var adapter = fixture as MutableDomainAdapter;
+ if (adapter != null) {
+ var parent = processor.CallStack.DomainAdapter.GetValueAs<DomainAdapter>();
+ adapter.SetSystemUnderTest(new MethodPhrase(firstRow.Skip(2)).Evaluate(parent, processor));
+ }
+ }
+ return fixture;
+ }
+ }
+}
View
2 source/fitSharp/Fit/Operators/CellOperators.cs
@@ -20,7 +20,7 @@ public class CellOperators: Operators<Cell, CellProcessor> {
Add(new ParseMemberName(), 0);
Add(new ParseBoolean(), 0);
Add(new ParseDate(), 0);
- Add(new ParseType(), 0);
+ Add(new ParseType<Cell, CellProcessor>(), 0);
Add(new ParseBlank(), 0);
Add(new ParseNull(), 0);
Add(new ParseInterpreter(), 0);
View
6 source/fitSharp/Fit/Operators/ParseInterpreter.cs
@@ -1,11 +1,12 @@
-// Copyright © 2011 Syterra Software Inc. All rights reserved.
+// Copyright © 2012 Syterra Software Inc. All rights reserved.
// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
using System;
using fitSharp.Fit.Engine;
using fitSharp.Fit.Fixtures;
+using fitSharp.Fit.Model;
using fitSharp.Machine.Engine;
using fitSharp.Machine.Model;
@@ -30,7 +31,7 @@ public class ParseInterpreter: CellOperator, ParseOperator<Cell> {
Interpreter MakeInterpreter(string className) {
if (className.Length == 0 || !char.IsLetter(className[0])) return new CommentFixture();
- var result = Processor.Create(className);
+ var result = Processor.Create(new GracefulNameMatcher(className, className + "fixture"), new CellTree());
return result.GetValueAs<Interpreter>() ?? WithSystemUnderTest(Processor.Create(DefaultFlowInterpreter).GetValueAs<Interpreter>(), result);
}
@@ -42,5 +43,6 @@ public class ParseInterpreter: CellOperator, ParseOperator<Cell> {
}
return interpreter;
}
+
}
}
View
39 source/fitSharp/Fit/Operators/ParseType.cs
@@ -1,39 +0,0 @@
-// Copyright © 2009 Syterra Software Inc. All rights reserved.
-// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
-// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
-// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
-
-using System;
-using fitSharp.Machine.Engine;
-using fitSharp.Machine.Model;
-
-namespace fitSharp.Fit.Operators {
- public class ParseType: CellOperator, ParseOperator<Cell> {
- public bool CanParse(Type type, TypedValue instance, Tree<Cell> parameters) {
- return type == typeof(Type) || type == typeof(RuntimeType);
- }
-
- public TypedValue Parse(Type type, TypedValue instance, Tree<Cell> parameters) {
- var runtimeType = Processor.ApplicationUnderTest.FindType(new TypeMatcher(parameters.Value.Text));
- return new TypedValue(type == typeof (RuntimeType) ? runtimeType : (object)runtimeType.Type, type);
- }
-
- private class TypeMatcher: NameMatcher {
- public string MatchName { get; private set; }
-
- public TypeMatcher(string matchName) {
- MatchName = matchName.Trim();
- }
-
- public bool Matches(string candidateName) {
- string baseName = candidateName.Contains(".")
- ? MatchName
- : new GracefulName(MatchName).IdentifierName.ToString();
- var typeIdentifier = new IdentifierName(baseName);
- //todo: only use when looking for fixtures
- var typeFixtureIdentifier = new IdentifierName(baseName + "fixture");
- return typeIdentifier.Matches(candidateName) || typeFixtureIdentifier.Matches(candidateName);
- }
- }
- }
-}
View
6 source/fitSharp/Machine/Engine/CreateDefault.cs
@@ -8,12 +8,12 @@
namespace fitSharp.Machine.Engine {
public class CreateDefault<T,P>: Operator<T, P>, CreateOperator<T> where P: class, Processor<T> {
- public bool CanCreate(string memberName, Tree<T> parameters) {
+ public bool CanCreate(NameMatcher memberName, Tree<T> parameters) {
return true;
}
- public TypedValue Create(string memberName, Tree<T> parameters) {
- var runtimeType = Processor.ParseString<T, RuntimeType>(memberName);
+ public TypedValue Create(NameMatcher memberName, Tree<T> parameters) {
+ var runtimeType = Processor.ApplicationUnderTest.FindType(memberName);
return parameters.Branches.Count == 0
? CreateWithoutParameters(runtimeType)
: CreateWithParameters(parameters, runtimeType);
View
4 source/fitSharp/Machine/Engine/Operator.cs
@@ -40,8 +40,8 @@ public interface ParseOperator<T> {
}*/
public interface CreateOperator<T> {
- bool CanCreate(string memberName, Tree<T> parameters);
- TypedValue Create(string memberName, Tree<T> parameters);
+ bool CanCreate(NameMatcher memberName, Tree<T> parameters);
+ TypedValue Create(NameMatcher memberName, Tree<T> parameters);
}
public interface InvokeOperator<T> {
View
10 source/fitSharp/Machine/Engine/ParseType.cs
@@ -1,4 +1,4 @@
-// Copyright © 2009 Syterra Software Inc. All rights reserved.
+// Copyright © 2012 Syterra Software Inc. All rights reserved.
// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
@@ -9,11 +9,13 @@
namespace fitSharp.Machine.Engine {
public class ParseType<T,P>: Operator<T, P>, ParseOperator<T> where P: class, Processor<T> {
public bool CanParse(Type type, TypedValue instance, Tree<T> parameters) {
- return type == typeof (RuntimeType);
+ return type == typeof(Type) || type == typeof(RuntimeType);
}
public TypedValue Parse(Type type, TypedValue instance, Tree<T> parameters) {
- return new TypedValue(Processor.ApplicationUnderTest.FindType(new IdentifierName(parameters.Value.ToString())), type);
+ var typeName = Processor.ParseTree<T, string>(parameters);
+ var runtimeType = Processor.ApplicationUnderTest.FindType(new GracefulNameMatcher(typeName));
+ return new TypedValue(type == typeof (RuntimeType) ? runtimeType : (object)runtimeType.Type, type);
}
}
-}
+}
View
21 source/fitSharp/Machine/Engine/Processor.cs
@@ -35,6 +35,23 @@ public static class ProcessorExtension {
return processor.Create(membername, new TreeList<T>());
}
+ public static TypedValue Create<T>(this Processor<T> processor, Tree<T> memberNameCell) {
+ return processor.Create(memberNameCell, new TreeList<T>());
+ }
+
+ public static TypedValue Create<T>(this Processor<T> processor, string memberName, Tree<T> parameters) {
+ return processor.Create(new GracefulNameMatcher(memberName), parameters);
+ }
+
+ public static TypedValue Create<T>(this Processor<T> processor, Tree<T> memberNameCell, Tree<T> parameters) {
+ var memberName = processor.ParseTree<T, string>(memberNameCell);
+ return processor.Create(memberName, parameters);
+ }
+
+ public static TypedValue Create<T>(this Processor<T> processor, NameMatcher memberName, Tree<T> parameters) {
+ return processor.Operate<CreateOperator<T>>(memberName, parameters);
+ }
+
public static TypedValue InvokeWithThrow<T>(this Processor<T> processor, TypedValue instance, MemberName memberName,
Tree<T> parameters) {
TypedValue result = processor.Invoke(instance, memberName, parameters);
@@ -71,10 +88,6 @@ public static class ProcessorExtension {
return processor.ParseString(typeof (V), input).GetValue<V>();
}
- public static TypedValue Create<T>(this Processor<T> processor, string memberName, Tree<T> parameters) {
- return processor.Operate<CreateOperator<T>>(memberName, parameters);
- }
-
public static TypedValue FindMember<T>(this Processor<T> processor, TypedValue instance, MemberQuery query) {
return processor.Operate<FindMemberOperator<T>>(instance, query);
}
View
27 source/fitSharp/Machine/Model/GracefulNameMatcher.cs
@@ -0,0 +1,27 @@
+// Copyright © 2012 Syterra Software Inc. All rights reserved.
+// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
+// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
+
+using System.Linq;
+
+namespace fitSharp.Machine.Model {
+ public class GracefulNameMatcher: NameMatcher {
+ public GracefulNameMatcher(params string[] originalNames) {
+ matchers = originalNames.Select(originalName =>
+ originalName.Contains(".")
+ ? new IdentifierName(originalName)
+ : new GracefulName(originalName).IdentifierName).ToArray();
+ }
+
+ public bool Matches(string candidateName) {
+ return matchers.Any(matcher => matcher.Matches(candidateName));
+ }
+
+ public string MatchName {
+ get { return matchers[0].MatchName; }
+ }
+
+ readonly IdentifierName[] matchers;
+ }
+}
View
30 source/fitSharp/Machine/Model/LanguageName.cs
@@ -1,30 +0,0 @@
-// Copyright © 2009 Syterra Software Inc. All rights reserved.
-// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
-// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
-// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
-
-namespace fitSharp.Machine.Model {
- public class LanguageName: NameMatcher {
-
- public string MatchName { get; private set; }
-
- public LanguageName(string name) {
- MatchName = name.Trim();
- }
-
- public bool Matches(string candidateName) {
- return candidateName == MatchName;
- }
-
- public override bool Equals(object otherObject) {
- return Equals(otherObject as LanguageName);
- }
-
- public bool Equals(LanguageName other) {
- return other != null && Matches(other.MatchName);
- }
-
- public override string ToString() { return MatchName; }
- public override int GetHashCode() { return MatchName.GetHashCode(); }
- }
-}
View
13 source/fitSharp/Slim/Operators/ExecuteMake.cs
@@ -1,4 +1,4 @@
-// Copyright © 2011 Syterra Software Inc. All rights reserved.
+// Copyright © 2012 Syterra Software Inc. All rights reserved.
// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
@@ -15,13 +15,18 @@ public class ExecuteMake: InvokeInstructionBase {
var singleSymbol = Processor.LoadSymbol(parameters.ValueAt(3));
var newInstance = singleSymbol.IsObject
? singleSymbol
- : Processor.Create(parameters.ValueAt(3), ParameterTree(parameters, 4));
- string name = parameters.ValueAt(2);
+ : CreateInstance(parameters);
+ var name = parameters.ValueAt(2);
Processor.Get<SavedInstances>().Save(name, newInstance.Value);
if (name.StartsWith("library")) {
Processor.PushLibraryInstance(newInstance);
}
return DefaultResult(parameters);
}
+
+ TypedValue CreateInstance(Tree<string> parameters) {
+ var typeName = Processor.ParseTree<string, string>(parameters.Branches[3]);
+ return Processor.Create(typeName, ParameterTree(parameters, 4));
+ }
}
-}
+}
View
5 source/fitSharp/fitSharp.csproj
@@ -45,6 +45,7 @@
<Compile Include="Fit\Engine\DefaultFlowInterpreter.cs" />
<Compile Include="Fit\Engine\ListMatcher.cs" />
<Compile Include="Fit\Engine\ListMatchStrategy.cs" />
+ <Compile Include="Fit\Exception\FitFailureException.cs" />
<Compile Include="Fit\Exception\InvalidMethodException.cs" />
<Compile Include="Fit\Exception\TableStructureException.cs" />
<Compile Include="Fit\Fixtures\ClearSymbols.cs" />
@@ -56,6 +57,7 @@
<Compile Include="Fit\Fixtures\Include.cs" />
<Compile Include="Fit\Fixtures\IncludeAction.cs" />
<Compile Include="Fit\Engine\MethodPhrase.cs" />
+ <Compile Include="Fit\Fixtures\UseFixture.cs" />
<Compile Include="Fit\Model\CallStack.cs" />
<Compile Include="Fit\Model\MethodRowSelector.cs" />
<Compile Include="Fit\Model\Procedures.cs" />
@@ -159,6 +161,7 @@
<Compile Include="Fit\Operators\CompareFloatingPoint.cs" />
<Compile Include="Fit\Operators\ParseMemberName.cs" />
<Compile Include="Machine\Model\GracefulName.cs" />
+ <Compile Include="Machine\Model\GracefulNameMatcher.cs" />
<Compile Include="Machine\Model\Maybe.cs" />
<Compile Include="Machine\Model\MemberName.cs" />
<Compile Include="Fit\Operators\CompareDefault.cs" />
@@ -171,7 +174,6 @@
<Compile Include="Fit\Operators\ParseBoolean.cs" />
<Compile Include="Fit\Operators\ParseDefault.cs" />
<Compile Include="Fit\Operators\ParseNull.cs" />
- <Compile Include="Fit\Operators\ParseType.cs" />
<Compile Include="Machine\Engine\Memory.cs" />
<Compile Include="Machine\Application\Shell.cs" />
<Compile Include="Machine\Engine\ApplicationUnderTest.cs" />
@@ -209,7 +211,6 @@
<Compile Include="Machine\Model\DomainAdapter.cs" />
<Compile Include="Machine\Model\EnumeratedTree.cs" />
<Compile Include="Machine\Model\IdentifierName.cs" />
- <Compile Include="Machine\Model\LanguageName.cs" />
<Compile Include="Machine\Model\NameMatcher.cs" />
<Compile Include="Machine\Model\Tree.cs" />
<Compile Include="Machine\Model\TreeList.cs" />
View
4 source/fitSharpTest/NUnit/Machine/CreateDefaultTest.cs
@@ -17,12 +17,12 @@ namespace fitSharp.Test.NUnit.Machine {
}
[Test] public void InstanceIsCreated() {
- TypedValue result = runtime.Create(typeof(SampleClass).FullName, new TreeList<string>());
+ TypedValue result = runtime.Create(new IdentifierName(typeof(SampleClass).FullName), new TreeList<string>());
Assert.IsTrue(result.Value is SampleClass);
}
[Test] public void StandardInstanceIsCreated() {
- TypedValue result = runtime.Create("System.Boolean", new TreeList<string>());
+ TypedValue result = runtime.Create(new IdentifierName("System.Boolean"), new TreeList<string>());
Assert.IsTrue(result.Value is bool);
}
}
View
19 source/fitSharpTest/NUnit/Machine/LanguageNameTest.cs
@@ -1,19 +0,0 @@
-// Copyright © 2009 Syterra Software Inc. All rights reserved.
-// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
-// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
-// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
-
-using fitSharp.Machine.Model;
-using NUnit.Framework;
-
-namespace fitSharp.Test.NUnit.Machine {
- [TestFixture] public class LanguageNameTest {
- [Test] public void MatchesString() {
- Assert.IsTrue(new LanguageName("stuff").Matches("stuff"));
- }
-
- [Test] public void WhitespaceIsTrimmed() {
- Assert.IsTrue(new LanguageName(" stuff\n").Matches("stuff"));
- }
- }
-}
View
6 source/fitSharpTest/NUnit/Machine/OperatorsTest.cs
@@ -8,16 +8,16 @@ namespace fitSharp.Test.NUnit.Machine {
[Test] public void FindsDefaultOperator() {
var operators = new Operators<string, Processor<string>>();
operators.Add(new DefaultCreate());
- var result = operators.FindOperator<CreateOperator<string>>(new [] {"test", null});
+ var result = operators.FindOperator<CreateOperator<string>>(new [] {new IdentifierName("test"), null});
Assert.AreEqual(typeof(DefaultCreate), result.GetType());
}
class DefaultCreate: Operator<string, Processor<string>>, CreateOperator<string> {
- public bool CanCreate(string memberName, Tree<string> parameters) {
+ public bool CanCreate(NameMatcher memberName, Tree<string> parameters) {
return true;
}
- public TypedValue Create(string memberName, Tree<string> parameters) {
+ public TypedValue Create(NameMatcher memberName, Tree<string> parameters) {
return TypedValue.Void;
}
}
View
1 source/fitSharpTest/fitSharpTest.csproj
@@ -89,7 +89,6 @@
<Compile Include="NUnit\Machine\DefaultParseTest.cs" />
<Compile Include="NUnit\Machine\InvokeDefaultTest.cs" />
<Compile Include="NUnit\Machine\IdentifierNameTest.cs" />
- <Compile Include="NUnit\Machine\LanguageNameTest.cs" />
<Compile Include="NUnit\Machine\ProcessorTest.cs" />
<Compile Include="NUnit\Machine\MemberQueryTest.cs" />
<Compile Include="Double\SampleClass.cs" />
View
2 source/fitTest/Acceptance/SpecifyFixture.cs
@@ -5,7 +5,7 @@
using fit.Operators;
using fitlibrary;
-using fitlibrary.exception;
+using fitSharp.Fit.Exception;
using fitSharp.Fit.Fixtures;
using fitSharp.Fit.Model;
using fitSharp.Machine.Model;
View
2 source/fitTest/Acceptance/SystemUnderTest.cs
@@ -6,7 +6,7 @@
using System;
using System.Collections;
using fitlibrary;
-using fitlibrary.exception;
+using fitSharp.Fit.Exception;
namespace fit.Test.Acceptance {
public class SystemUnderTest {
View
15 source/fitTest/Acceptance/TypeName.cs
@@ -1,8 +1,9 @@
-// Copyright © 2009 Syterra Software Inc.
+// Copyright © 2012 Syterra Software Inc.
// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+using fitSharp.Fit.Engine;
using fitSharp.Fit.Model;
using fitSharp.Machine.Engine;
using fitSharp.Machine.Model;
@@ -16,6 +17,14 @@ public class TypeNameFixture: ColumnFixture {
public string TypeName;
- public string FullName { get { return Processor.Create(TypeName).Type.FullName; } }
+ public string FullName {
+ get {
+ var interpreter = Processor.ParseTree<Cell, Interpreter>(new CellTree(TypeName));
+ var adapter = interpreter as DomainAdapter;
+ return adapter != null && adapter.SystemUnderTest != null
+ ? adapter.SystemUnderTest.GetType().FullName
+ : interpreter.GetType().FullName;
+ }
+ }
}
-}
+}
View
2 source/fitTest/NUnit/CellMatching.cs
@@ -84,7 +84,7 @@ namespace fit.Test.NUnit {
Parse table = Parse.ParseFrom("<table><tr><td><table><tr><td>first</td><td>last</td><td>address</td></tr><tr><td>joe</td><td>smith</td><td></td></tr></table></td></tr></table>");
var fixture = new Fixture {Processor = new Service.Service()};
fixture.Processor.Check(new TypedValue(actual), table.Parts.Parts);
- Assert.AreEqual("<td><table><tr><td>first</td><td>last</td><td class=\"error\">address<hr /><pre><div class=\"fit_stacktrace\">fitlibrary.exception.FitFailureException: Column 'address' not used.</div></pre></td></tr><tr><td class=\"pass\">joe</td><td class=\"pass\">smith</td><td></td></tr></table></td>", table.Parts.Parts.ToString());
+ Assert.AreEqual("<td><table><tr><td>first</td><td>last</td><td class=\"error\">address<hr /><pre><div class=\"fit_stacktrace\">fitSharp.Fit.Exception.FitFailureException: Column 'address' not used.</div></pre></td></tr><tr><td class=\"pass\">joe</td><td class=\"pass\">smith</td><td></td></tr></table></td>", table.Parts.Parts.ToString());
}
private class Name {
View
1 storytest.config.xml
@@ -14,6 +14,7 @@
<addNamespace>fit.Test.Acceptance</addNamespace>
<addNamespace>fit.Test.Double</addNamespace>
<addNamespace>fitSharp.Test.Double</addNamespace>
+ <addNamespace>fitSharp.Samples</addNamespace>
<addNamespace>fit.Runner</addNamespace>
<addNamespace>fitSharp.Fit.Runner</addNamespace>
<addNamespace>fitSharp.Fit.Model</addNamespace>

0 comments on commit 5b4c934

Please sign in to comment.