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.
Made richstring tests work on windows
- Loading branch information
Showing
6 changed files
with
546 additions
and
483 deletions.
There are no files selected for viewing
270 changes: 135 additions & 135 deletions
270
tests/org.jnario.tests/src/org/jnario/jnario/tests/unit/jnario/RichStrings.spec
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,136 +1,136 @@ | ||
package org.jnario.jnario.tests.unit.jnario | ||
|
||
describe "RichStrings"{ | ||
context "as expression"{ | ||
|
||
fact "richstring should be"{ | ||
//dont assign to variable, use directly | ||
'''abc''' should be "abc" | ||
} | ||
|
||
fact "richstring with if"{ | ||
'''a «IF true»b«ENDIF»''' should be "a b" | ||
} | ||
} | ||
|
||
context "tab, newline, etc."{ | ||
|
||
fact "tabs"{ | ||
//Table does not format correctly yet | ||
''' leading Tab''' should be "\tleading Tab" | ||
'''trailing Tab ''' should be "trailing Tab\t" | ||
'''inner tab''' should be "inner\ttab" | ||
} | ||
|
||
fact "spaces"{ | ||
//Table does not format correctly yet | ||
''' leading ws''' should be " leading ws" | ||
'''trailing ws ''' should be "trailing ws " | ||
'''inner ws''' should be "inner ws" | ||
} | ||
|
||
fact "newlines"{ | ||
''' | ||
line1 | ||
line2''' should be "line1\nline2" | ||
} | ||
|
||
fact "empty newlines"{ | ||
''' | ||
line1 | ||
line2''' should be "line1\n\nline2" | ||
} | ||
} | ||
|
||
context "expressions in richstrings"{ | ||
fact "a variable"{ | ||
val x = "value" | ||
'''pre «x» post''' should be "pre value post" | ||
} | ||
|
||
fact "multiple variables"{ | ||
val x = "value" | ||
val y = "value2" | ||
'''pre «x» «y» post''' should be "pre value value2 post" | ||
} | ||
|
||
fact "multiple variables in new lines"{ | ||
val x = "value" | ||
val y = "value2" | ||
''' | ||
pre | ||
«x» | ||
«y» | ||
post''' should be "pre\nvalue\nvalue2\npost" | ||
} | ||
|
||
fact "expression"{ | ||
'''1 + 2 = «1+2»''' should be "1 + 2 = 3" | ||
} | ||
|
||
fact "expression with variables"{ | ||
val a = 1 | ||
val b = 2 | ||
'''«a» + «b» = «a + b»''' should be "1 + 2 = 3" | ||
} | ||
} | ||
|
||
context "indentation"{ | ||
|
||
fact "no indentation"{ | ||
''' | ||
a | ||
b''' should be "a\nb" | ||
} | ||
|
||
fact "with indentation"{ | ||
''' | ||
a | ||
b''' should be "a\n\tb" | ||
|
||
''' | ||
a | ||
b''' should be "\ta\nb" | ||
} | ||
} | ||
|
||
context "if condition"{ | ||
fact "if false"{ | ||
val stringWithIf = '''pre«IF false» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("prepost", stringWithIf) | ||
} | ||
|
||
fact "if true"{ | ||
val stringWithIf = '''pre«IF true» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("pre x post", stringWithIf) | ||
} | ||
|
||
fact "if expression"{ | ||
var stringWithIf = '''pre«IF 3 > 2» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("pre x post", stringWithIf) | ||
|
||
stringWithIf = '''pre«IF 3 < 2» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("prepost", stringWithIf) | ||
} | ||
} | ||
|
||
context "loop" { | ||
fact "for 1..3"{ | ||
val x = ''' | ||
«FOR x : (1..3)» | ||
line «x» | ||
«ENDFOR» | ||
''' | ||
|
||
org.junit.Assert.assertEquals("line 1\nline 2\nline 3\n", x) | ||
} | ||
|
||
fact "for before after"{ | ||
val text = ''' | ||
«FOR x : (1..3) BEFORE 'pre ' SEPARATOR ',' AFTER ' post'»«x»«ENDFOR»''' | ||
|
||
org.junit.Assert.assertEquals("pre 1,2,3 post", text) | ||
} | ||
} | ||
package org.jnario.jnario.tests.unit.jnario | ||
|
||
describe "RichStrings"{ | ||
context "as expression"{ | ||
|
||
fact "richstring should be"{ | ||
//dont assign to variable, use directly | ||
'''abc''' should be "abc" | ||
} | ||
|
||
fact "richstring with if"{ | ||
'''a «IF true»b«ENDIF»''' should be "a b" | ||
} | ||
} | ||
|
||
context "tab, newline, etc."{ | ||
|
||
fact "tabs"{ | ||
//Table does not format correctly yet | ||
''' leading Tab''' should be "\tleading Tab" | ||
'''trailing Tab ''' should be "trailing Tab\t" | ||
'''inner tab''' should be "inner\ttab" | ||
} | ||
|
||
fact "spaces"{ | ||
//Table does not format correctly yet | ||
''' leading ws''' should be " leading ws" | ||
'''trailing ws ''' should be "trailing ws " | ||
'''inner ws''' should be "inner ws" | ||
} | ||
|
||
fact "newlines"{ | ||
''' | ||
line1 | ||
line2''' should be "line1"+System.lineSeparator()+"line2" | ||
} | ||
|
||
fact "empty newlines"{ | ||
''' | ||
line1 | ||
line2''' should be "line1"+System.lineSeparator()+System.lineSeparator()+"line2" | ||
} | ||
} | ||
|
||
context "expressions in richstrings"{ | ||
fact "a variable"{ | ||
val x = "value" | ||
'''pre «x» post''' should be "pre value post" | ||
} | ||
|
||
fact "multiple variables"{ | ||
val x = "value" | ||
val y = "value2" | ||
'''pre «x» «y» post''' should be "pre value value2 post" | ||
} | ||
|
||
fact "multiple variables in new lines"{ | ||
val x = "value" | ||
val y = "value2" | ||
''' | ||
pre | ||
«x» | ||
«y» | ||
post''' should be "pre"+System.lineSeparator()+"value"+System.lineSeparator()+"value2"+System.lineSeparator()+"post" | ||
} | ||
|
||
fact "expression"{ | ||
'''1 + 2 = «1+2»''' should be "1 + 2 = 3" | ||
} | ||
|
||
fact "expression with variables"{ | ||
val a = 1 | ||
val b = 2 | ||
'''«a» + «b» = «a + b»''' should be "1 + 2 = 3" | ||
} | ||
} | ||
|
||
context "indentation"{ | ||
|
||
fact "no indentation"{ | ||
''' | ||
a | ||
b''' should be "a"+System.lineSeparator()+"b" | ||
} | ||
|
||
fact "with indentation"{ | ||
''' | ||
a | ||
b''' should be "a"+System.lineSeparator()+"\tb" | ||
|
||
''' | ||
a | ||
b''' should be "\ta"+System.lineSeparator()+"b" | ||
} | ||
} | ||
|
||
context "if condition"{ | ||
fact "if false"{ | ||
val stringWithIf = '''pre«IF false» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("prepost", stringWithIf) | ||
} | ||
|
||
fact "if true"{ | ||
val stringWithIf = '''pre«IF true» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("pre x post", stringWithIf) | ||
} | ||
|
||
fact "if expression"{ | ||
var stringWithIf = '''pre«IF 3 > 2» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("pre x post", stringWithIf) | ||
|
||
stringWithIf = '''pre«IF 3 < 2» x «ENDIF»post''' | ||
org.junit.Assert.assertEquals("prepost", stringWithIf) | ||
} | ||
} | ||
|
||
context "loop" { | ||
fact "for 1..3"{ | ||
val x = ''' | ||
«FOR x : (1..3)» | ||
line «x» | ||
«ENDFOR» | ||
''' | ||
|
||
org.junit.Assert.assertEquals("line 1"+System.lineSeparator()+"line 2"+System.lineSeparator()+"line 3"+System.lineSeparator(), x) | ||
} | ||
|
||
fact "for before after"{ | ||
val text = ''' | ||
«FOR x : (1..3) BEFORE 'pre ' SEPARATOR ',' AFTER ' post'»«x»«ENDFOR»''' | ||
|
||
org.junit.Assert.assertEquals("pre 1,2,3 post", text) | ||
} | ||
} | ||
} |
86 changes: 43 additions & 43 deletions
86
...ario.tests/xtend-gen/org/jnario/jnario/tests/unit/jnario/RichStringsAsExpressionSpec.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,43 +1,43 @@ | ||
package org.jnario.jnario.tests.unit.jnario; | ||
|
||
import org.eclipse.xtend2.lib.StringConcatenation; | ||
import org.jnario.jnario.tests.unit.jnario.RichStringsSpec; | ||
import org.jnario.lib.Assert; | ||
import org.jnario.lib.Should; | ||
import org.jnario.runner.ExampleGroupRunner; | ||
import org.jnario.runner.Named; | ||
import org.jnario.runner.Order; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@Named("as expression") | ||
@RunWith(ExampleGroupRunner.class) | ||
@SuppressWarnings("all") | ||
public class RichStringsAsExpressionSpec extends RichStringsSpec { | ||
@Test | ||
@Named("richstring should be") | ||
@Order(1) | ||
public void _richstringShouldBe() throws Exception { | ||
StringConcatenation _builder = new StringConcatenation(); | ||
_builder.append("abc"); | ||
Assert.assertTrue("\nExpected //dont assign to variable, use directly\n\t\t\t\'\'\'abc\'\'\' should be \"abc\" but" | ||
+ "\n //dont assign to variable, use directly\n\t\t\t\'\'\'abc\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder.toString()).toString() + "\n", Should.<String>should_be(_builder.toString(), "abc")); | ||
|
||
} | ||
|
||
@Test | ||
@Named("richstring with if") | ||
@Order(2) | ||
public void _richstringWithIf() throws Exception { | ||
StringConcatenation _builder = new StringConcatenation(); | ||
_builder.append("a "); | ||
{ | ||
if (true) { | ||
_builder.append("b"); | ||
} | ||
} | ||
Assert.assertTrue("\nExpected \'\'\'a \u00ABIF true\u00BBb\u00ABENDIF\u00BB\'\'\' should be \"a b\" but" | ||
+ "\n \'\'\'a \u00ABIF true\u00BBb\u00ABENDIF\u00BB\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder.toString()).toString() + "\n", Should.<String>should_be(_builder.toString(), "a b")); | ||
|
||
} | ||
} | ||
package org.jnario.jnario.tests.unit.jnario; | ||
|
||
import org.eclipse.xtend2.lib.StringConcatenation; | ||
import org.jnario.jnario.tests.unit.jnario.RichStringsSpec; | ||
import org.jnario.lib.Assert; | ||
import org.jnario.lib.Should; | ||
import org.jnario.runner.ExampleGroupRunner; | ||
import org.jnario.runner.Named; | ||
import org.jnario.runner.Order; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@Named("as expression") | ||
@RunWith(ExampleGroupRunner.class) | ||
@SuppressWarnings("all") | ||
public class RichStringsAsExpressionSpec extends RichStringsSpec { | ||
@Test | ||
@Named("richstring should be") | ||
@Order(1) | ||
public void _richstringShouldBe() throws Exception { | ||
StringConcatenation _builder = new StringConcatenation(); | ||
_builder.append("abc"); | ||
Assert.assertTrue("\nExpected //dont assign to variable, use directly\r\n\t\t\t\'\'\'abc\'\'\' should be \"abc\" but" | ||
+ "\n //dont assign to variable, use directly\r\n\t\t\t\'\'\'abc\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder.toString()).toString() + "\n", Should.<String>should_be(_builder.toString(), "abc")); | ||
|
||
} | ||
|
||
@Test | ||
@Named("richstring with if") | ||
@Order(2) | ||
public void _richstringWithIf() throws Exception { | ||
StringConcatenation _builder = new StringConcatenation(); | ||
_builder.append("a "); | ||
{ | ||
if (true) { | ||
_builder.append("b"); | ||
} | ||
} | ||
Assert.assertTrue("\nExpected \'\'\'a \u00ABIF true\u00BBb\u00ABENDIF\u00BB\'\'\' should be \"a b\" but" | ||
+ "\n \'\'\'a \u00ABIF true\u00BBb\u00ABENDIF\u00BB\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder.toString()).toString() + "\n", Should.<String>should_be(_builder.toString(), "a b")); | ||
|
||
} | ||
} |
Oops, something went wrong.