forked from borisbrodski/Jnario
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sebastianbenz#18 from ghaith/fix_richstring_tests
Issue sebastianbenz#23 Fix richstring tests
- Loading branch information
Showing
124 changed files
with
14,194 additions
and
14,032 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
examples/org.jnario.examples/doc-gen/diverse/StackStringSpec.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Stack<String></title> | ||
<meta name="description" content=""> | ||
<meta name="author" content="Jnario"> | ||
|
||
<!--[if lt IE 9]> | ||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
|
||
<link rel="stylesheet" href="../css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="../css/bootstrap-responsive.min.css"> | ||
<link rel="stylesheet" href="../css/custom.css"> | ||
<link rel="stylesheet" href="../css/prettify.css"> | ||
<script type="text/javascript" src="../js/prettify.js"></script> | ||
<script type="text/javascript" src="../js/lang-jnario.js"></script> | ||
<script type="text/javascript" src="../js/jquery.js"></script> | ||
<script type="text/javascript" src="../js/bootstrap-tab.js"></script> | ||
</head> | ||
|
||
<body onload="prettyPrint()"> | ||
<div class="container"> | ||
<div class="tabbable"> | ||
<div class="content"> | ||
<div class="page-header notrun"> | ||
<h1>Stack<String></h1> | ||
<ul class="nav nav-tabs pull-right"> | ||
<li class="active"><a href="#spec" data-toggle="tab">Spec</a></li> | ||
<li><a href="#source" data-toggle="tab">Source</a></li> | ||
</ul> | ||
</div> | ||
<div class="row"> | ||
<div class="span12"> | ||
<div class="tab-content"> | ||
<div class="tab-pane active" id="spec"> | ||
<h3 class="exampleGroup notrun" id="empty">Empty</h3> | ||
<ul><li><p id="subject_empty_should_be_true" class="example notrun"><strong>subject.empty[] should be true</strong></p> | ||
</li><li><p id="subject_pop_throws_EmptyStackException" class="example notrun"><strong>subject.pop[] throws EmptyStackException</strong></p> | ||
</li></ul> | ||
<h3 class="exampleGroup notrun" id="not_empty">Not empty</h3> | ||
<ul><li><p id="increases_size_when_pushing" class="example notrun"><strong>increases size when pushing</strong></p> | ||
<pre class="prettyprint lang-spec linenums"> | ||
subject.push("something") | ||
subject.size => 1</pre> | ||
</li><li><p id="decreases_size_when_popping" class="example notrun"><strong>decreases size when popping</strong></p> | ||
<pre class="prettyprint lang-spec linenums"> | ||
subject.push("something") | ||
subject.pop() | ||
subject.size => 0</pre> | ||
</li></ul> | ||
</div> | ||
<div class="tab-pane" id="source"> | ||
<h3>Stack.spec</h3> | ||
<p> | ||
<pre class="prettyprint lang-spec linenums"> | ||
/******************************************************************************* | ||
* Copyright (c) 2012 BMW Car IT and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package diverse | ||
|
||
import java.util.EmptyStackException | ||
import java.util.Stack | ||
|
||
describe Stack<String>{ | ||
context "empty"{ | ||
fact subject.empty() should be true | ||
fact subject.pop() throws EmptyStackException | ||
} | ||
context "not empty"{ | ||
fact "increases size when pushing"{ | ||
subject.push("something") | ||
subject.size => 1 | ||
} | ||
fact "decreases size when popping"{ | ||
subject.push("something") | ||
subject.pop() | ||
subject.size => 0 | ||
} | ||
} | ||
} | ||
</pre> | ||
</p></div> | ||
</div> | ||
</div> | ||
</div> <!-- /row --> | ||
</div> <!-- /content --> | ||
</div> <!-- /tabbable --> | ||
<footer> | ||
<p><small>Generated by <a href="http://www.jnario.org">Jnario</a>.</small></p> | ||
</footer> | ||
</div> <!-- /container --> | ||
|
||
</body> | ||
</html> |
94 changes: 45 additions & 49 deletions
94
examples/org.jnario.examples/xtend-gen/calculator/AdditionFeatureAddTwoNumbers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,45 @@ | ||
package calculator; | ||
|
||
import calculator.AdditionFeature; | ||
import calculator.Calculator; | ||
import org.jnario.lib.Assert; | ||
import org.jnario.lib.JnarioIterableExtensions; | ||
import org.jnario.lib.Should; | ||
import org.jnario.lib.StepArguments; | ||
import org.jnario.lib.StringConversions; | ||
import org.jnario.runner.FeatureRunner; | ||
import org.jnario.runner.Named; | ||
import org.jnario.runner.Order; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(FeatureRunner.class) | ||
@Named("Scenario: Add two numbers") | ||
@SuppressWarnings("all") | ||
public class AdditionFeatureAddTwoNumbers extends AdditionFeature { | ||
final Calculator calculator = new Calculator(); | ||
|
||
int result; | ||
|
||
@Test | ||
@Order(0) | ||
@Named("When I entered \\\"50\\\" and \\\"70\\\"") | ||
public void _whenIEntered50And70() { | ||
final StepArguments args = new StepArguments("50", "70"); | ||
String _first = JnarioIterableExtensions.<String>first(args); | ||
String _second = JnarioIterableExtensions.<String>second(args); | ||
int _add = this.calculator.add(_first, _second); | ||
this.result = _add; | ||
} | ||
|
||
@Test | ||
@Order(1) | ||
@Named("Then the result should be \\\"120\\\"") | ||
public void _thenTheResultShouldBe120() { | ||
final StepArguments args = new StepArguments("120"); | ||
String _first = JnarioIterableExtensions.<String>first(args); | ||
int _int = StringConversions.toInt(_first); | ||
Assert.assertTrue("\nExpected result => args.first.toInt but" | ||
+ "\n result is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(this.result)).toString() | ||
+ "\n args.first.toInt is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_int)).toString() | ||
+ "\n args.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString() | ||
+ "\n args is " + new org.hamcrest.StringDescription().appendValue(args).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(this.result), Integer.valueOf(_int))); | ||
|
||
} | ||
} | ||
package calculator; | ||
|
||
import calculator.AdditionFeature; | ||
import calculator.Calculator; | ||
import org.jnario.lib.Assert; | ||
import org.jnario.lib.JnarioIterableExtensions; | ||
import org.jnario.lib.Should; | ||
import org.jnario.lib.StepArguments; | ||
import org.jnario.lib.StringConversions; | ||
import org.jnario.runner.FeatureRunner; | ||
import org.jnario.runner.Named; | ||
import org.jnario.runner.Order; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(FeatureRunner.class) | ||
@Named("Scenario: Add two numbers") | ||
@SuppressWarnings("all") | ||
public class AdditionFeatureAddTwoNumbers extends AdditionFeature { | ||
final Calculator calculator = new Calculator(); | ||
|
||
int result; | ||
|
||
@Test | ||
@Order(0) | ||
@Named("When I entered \\\"50\\\" and \\\"70\\\"") | ||
public void _whenIEntered50And70() { | ||
final StepArguments args = new StepArguments("50", "70"); | ||
this.result = this.calculator.add(JnarioIterableExtensions.<String>first(args), JnarioIterableExtensions.<String>second(args)); | ||
} | ||
|
||
@Test | ||
@Order(1) | ||
@Named("Then the result should be \\\"120\\\"") | ||
public void _thenTheResultShouldBe120() { | ||
final StepArguments args = new StepArguments("120"); | ||
int _int = StringConversions.toInt(JnarioIterableExtensions.<String>first(args)); | ||
Assert.assertTrue("\nExpected result => args.first.toInt but" | ||
+ "\n result is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(this.result)).toString() | ||
+ "\n args.first.toInt is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_int)).toString() | ||
+ "\n args.first is " + new org.hamcrest.StringDescription().appendValue(JnarioIterableExtensions.<String>first(args)).toString() | ||
+ "\n args is " + new org.hamcrest.StringDescription().appendValue(args).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(this.result), Integer.valueOf(_int))); | ||
|
||
} | ||
} |
66 changes: 32 additions & 34 deletions
66
examples/org.jnario.examples/xtend-gen/calculator/Calculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
/** | ||
* Copyright (c) 2012 BMW Car IT and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package calculator; | ||
|
||
@SuppressWarnings("all") | ||
public class Calculator { | ||
public int add(final String a, final String b) { | ||
Integer _valueOf = Integer.valueOf(a); | ||
Integer _valueOf_1 = Integer.valueOf(b); | ||
return this.add((_valueOf).intValue(), (_valueOf_1).intValue()); | ||
} | ||
|
||
public int add(final int a, final int b) { | ||
return (a + b); | ||
} | ||
|
||
public int divide(final int a, final int b) { | ||
return (a / b); | ||
} | ||
|
||
public int substract(final int a, final int b) { | ||
return (a - b); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Calculator"; | ||
} | ||
} | ||
/** | ||
* Copyright (c) 2012 BMW Car IT and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package calculator; | ||
|
||
@SuppressWarnings("all") | ||
public class Calculator { | ||
public int add(final String a, final String b) { | ||
return this.add((Integer.valueOf(a)).intValue(), (Integer.valueOf(b)).intValue()); | ||
} | ||
|
||
public int add(final int a, final int b) { | ||
return (a + b); | ||
} | ||
|
||
public int divide(final int a, final int b) { | ||
return (a / b); | ||
} | ||
|
||
public int substract(final int a, final int b) { | ||
return (a - b); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Calculator"; | ||
} | ||
} |
75 changes: 37 additions & 38 deletions
75
examples/org.jnario.examples/xtend-gen/calculator/SimpleCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
package calculator; | ||
|
||
import java.util.ArrayList; | ||
import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
import org.eclipse.xtext.xbase.lib.Functions.Function2; | ||
import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
|
||
@SuppressWarnings("all") | ||
public class SimpleCalculator { | ||
private final ArrayList<Integer> values = CollectionLiterals.<Integer>newArrayList(); | ||
|
||
private int result = 0; | ||
|
||
public boolean enter(final String string) { | ||
Integer _valueOf = Integer.valueOf(string); | ||
return this.values.add(_valueOf); | ||
} | ||
|
||
public int add() { | ||
final Function2<Integer, Integer, Integer> _function = new Function2<Integer, Integer, Integer>() { | ||
@Override | ||
public Integer apply(final Integer a, final Integer b) { | ||
return Integer.valueOf(((a).intValue() + (b).intValue())); | ||
} | ||
}; | ||
Integer _fold = IterableExtensions.<Integer, Integer>fold(this.values, Integer.valueOf(0), _function); | ||
return this.result = (_fold).intValue(); | ||
} | ||
|
||
public String result() { | ||
return Integer.valueOf(this.result).toString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Calculator"; | ||
} | ||
} | ||
package calculator; | ||
|
||
import java.util.ArrayList; | ||
import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
import org.eclipse.xtext.xbase.lib.Functions.Function2; | ||
import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
|
||
@SuppressWarnings("all") | ||
public class SimpleCalculator { | ||
private final ArrayList<Integer> values = CollectionLiterals.<Integer>newArrayList(); | ||
|
||
private int result = 0; | ||
|
||
public boolean enter(final String string) { | ||
Integer _valueOf = Integer.valueOf(string); | ||
return this.values.add(_valueOf); | ||
} | ||
|
||
public int add() { | ||
final Function2<Integer, Integer, Integer> _function = new Function2<Integer, Integer, Integer>() { | ||
@Override | ||
public Integer apply(final Integer a, final Integer b) { | ||
return Integer.valueOf(((a).intValue() + (b).intValue())); | ||
} | ||
}; | ||
return this.result = (IterableExtensions.<Integer, Integer>fold(this.values, Integer.valueOf(0), _function)).intValue(); | ||
} | ||
|
||
public String result() { | ||
return Integer.valueOf(this.result).toString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Calculator"; | ||
} | ||
} |
Oops, something went wrong.