Skip to content

Commit

Permalink
Merge pull request sebastianbenz#18 from ghaith/fix_richstring_tests
Browse files Browse the repository at this point in the history
Issue sebastianbenz#23 Fix richstring tests
  • Loading branch information
riederm authored Jun 12, 2017
2 parents 4de0a24 + 7b5de76 commit 660a381
Show file tree
Hide file tree
Showing 124 changed files with 14,194 additions and 14,032 deletions.
6 changes: 4 additions & 2 deletions Jnario.setup
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
<setupTask
xsi:type="setup.p2:P2Task">
<requirement
name="org.eclipse.xtend.sdk.feature.group"/>
name="org.eclipse.xtend.sdk.feature.group"
versionRange="[2.11.0,2.12.0)"/>
<requirement
name="org.eclipse.xtext.sdk.feature.group"/>
name="org.eclipse.xtext.sdk.feature.group"
versionRange="[2.11.0,2.12.0)"/>
<repository
url="http://download.eclipse.org/releases/neon"/>
<repository
Expand Down
100 changes: 100 additions & 0 deletions examples/org.jnario.examples/doc-gen/diverse/StackStringSpec.html
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(&quot;something&quot;)
subject.size =&gt; 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(&quot;something&quot;)
subject.pop()
subject.size =&gt; 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&lt;String&gt;{
context &quot;empty&quot;{
fact subject.empty() should be true
fact subject.pop() throws EmptyStackException
}
context &quot;not empty&quot;{
fact &quot;increases size when pushing&quot;{
subject.push(&quot;something&quot;)
subject.size =&gt; 1
}
fact &quot;decreases size when popping&quot;{
subject.push(&quot;something&quot;)
subject.pop()
subject.size =&gt; 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>
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 examples/org.jnario.examples/xtend-gen/calculator/Calculator.java
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";
}
}
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";
}
}
Loading

0 comments on commit 660a381

Please sign in to comment.