Best junit code snippet using org.hamcrest.StringDescription.toString
Source:SyntaxScannerSpec.java
...54 _builder.newLine();55 List<RGB> _scan = this.scan(_builder);56 RGB _first = JnarioIterableExtensions.<RGB>first(_scan);57 Assert.assertTrue("\nExpected \'\'\'\n\t\t#a comment\n\t\t\'\'\'.scan.first => COMMENT but"58 + "\n \'\'\'\n\t\t#a comment\n\t\t\'\'\'.scan.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()59 + "\n \'\'\'\n\t\t#a comment\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()60 + "\n \'\'\'\n\t\t#a comment\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()61 + "\n COMMENT is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.COMMENT).toString() + "\n", Should.<RGB>operator_doubleArrow(_first, IColorConstants.COMMENT));62 63 }64 65 @Test66 @Named("parse annotations")67 @Order(2)68 public void _parseAnnotations() throws Exception {69 StringConcatenation _builder = new StringConcatenation();70 _builder.append("@a comment");71 _builder.newLine();72 List<RGB> _scan = this.scan(_builder);73 RGB _first = JnarioIterableExtensions.<RGB>first(_scan);74 Assert.assertTrue("\nExpected \'\'\'\n\t\t@a comment\n\t\t\'\'\'.scan.first => ANNOTATION but"75 + "\n \'\'\'\n\t\t@a comment\n\t\t\'\'\'.scan.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()76 + "\n \'\'\'\n\t\t@a comment\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()77 + "\n \'\'\'\n\t\t@a comment\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()78 + "\n ANNOTATION is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.ANNOTATION).toString() + "\n", Should.<RGB>operator_doubleArrow(_first, IColorConstants.ANNOTATION));79 80 }81 82 @Test83 @Named("parse comments until EOL")84 @Order(3)85 public void _parseCommentsUntilEOL() throws Exception {86 List<RGB> _scan = this.scan(("#a comment" + Character.valueOf(AbstractRTextParser.EOL)));87 RGB _first = JnarioIterableExtensions.<RGB>first(_scan);88 Assert.assertTrue("\nExpected (\"#a comment\" + EOL).scan.first => COMMENT but"89 + "\n (\"#a comment\" + EOL).scan.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()90 + "\n (\"#a comment\" + EOL).scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()91 + "\n \"#a comment\" + EOL is " + new org.hamcrest.StringDescription().appendValue(("#a comment" + Character.valueOf(AbstractRTextParser.EOL))).toString()92 + "\n EOL is " + new org.hamcrest.StringDescription().appendValue(Character.valueOf(AbstractRTextParser.EOL)).toString()93 + "\n COMMENT is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.COMMENT).toString() + "\n", Should.<RGB>operator_doubleArrow(_first, IColorConstants.COMMENT));94 95 }96 97 @Test98 @Named("parse command")99 @Order(4)100 public void _parseCommand() throws Exception {101 StringConcatenation _builder = new StringConcatenation();102 _builder.append("Type name, label: /a/Reference");103 _builder.newLine();104 List<RGB> _scan = this.scan(_builder);105 RGB _first = JnarioIterableExtensions.<RGB>first(_scan);106 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.first => COMMAND but"107 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()108 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()109 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()110 + "\n COMMAND is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.COMMAND).toString() + "\n", Should.<RGB>operator_doubleArrow(_first, IColorConstants.COMMAND));111 112 }113 114 @Test115 @Named("parse command starting with \\\'_\\\'")116 @Order(5)117 public void _parseCommandStartingWith() throws Exception {118 StringConcatenation _builder = new StringConcatenation();119 _builder.append("Type _name, label: /a/Reference");120 _builder.newLine();121 List<RGB> _scan = this.scan(_builder);122 RGB _first = JnarioIterableExtensions.<RGB>first(_scan);123 Assert.assertTrue("\nExpected \'\'\'\n\t\tType _name, label: /a/Reference\n\t\t\'\'\'.scan.first => COMMAND but"124 + "\n \'\'\'\n\t\tType _name, label: /a/Reference\n\t\t\'\'\'.scan.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()125 + "\n \'\'\'\n\t\tType _name, label: /a/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()126 + "\n \'\'\'\n\t\tType _name, label: /a/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()127 + "\n COMMAND is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.COMMAND).toString() + "\n", Should.<RGB>operator_doubleArrow(_first, IColorConstants.COMMAND));128 129 }130 131 @Test132 @Named("parse identifier")133 @Order(6)134 public void _parseIdentifier() throws Exception {135 StringConcatenation _builder = new StringConcatenation();136 _builder.append("Type name, label: /a/Reference");137 _builder.newLine();138 List<RGB> _scan = this.scan(_builder);139 RGB _second = JnarioIterableExtensions.<RGB>second(_scan);140 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.second => IDENTIFIER but"141 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.second is " + new org.hamcrest.StringDescription().appendValue(_second).toString()142 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()143 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()144 + "\n IDENTIFIER is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.IDENTIFIER).toString() + "\n", Should.<RGB>operator_doubleArrow(_second, IColorConstants.IDENTIFIER));145 146 }147 148 @Test149 @Named("parse identifier with \\\'_\\\'")150 @Order(7)151 public void _parseIdentifierWith() throws Exception {152 StringConcatenation _builder = new StringConcatenation();153 _builder.append("Type name_with, label: /a/Reference");154 _builder.newLine();155 List<RGB> _scan = this.scan(_builder);156 RGB _second = JnarioIterableExtensions.<RGB>second(_scan);157 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name_with, label: /a/Reference\n\t\t\'\'\'.scan.second => IDENTIFIER but"158 + "\n \'\'\'\n\t\tType name_with, label: /a/Reference\n\t\t\'\'\'.scan.second is " + new org.hamcrest.StringDescription().appendValue(_second).toString()159 + "\n \'\'\'\n\t\tType name_with, label: /a/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()160 + "\n \'\'\'\n\t\tType name_with, label: /a/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()161 + "\n IDENTIFIER is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.IDENTIFIER).toString() + "\n", Should.<RGB>operator_doubleArrow(_second, IColorConstants.IDENTIFIER));162 163 }164 165 @Test166 @Named("parse separator")167 @Order(8)168 public void _parseSeparator() throws Exception {169 StringConcatenation _builder = new StringConcatenation();170 _builder.append("Type name, label: /a/Reference");171 _builder.newLine();172 List<RGB> _scan = this.scan(_builder);173 RGB _third = JnarioIterableExtensions.<RGB>third(_scan);174 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.third => DEFAULT but"175 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.third is " + new org.hamcrest.StringDescription().appendValue(_third).toString()176 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()177 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()178 + "\n DEFAULT is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.DEFAULT).toString() + "\n", Should.<RGB>operator_doubleArrow(_third, IColorConstants.DEFAULT));179 180 }181 182 @Test183 @Named("parse label")184 @Order(9)185 public void _parseLabel() throws Exception {186 StringConcatenation _builder = new StringConcatenation();187 _builder.append("Type name, label: /a/Reference");188 _builder.newLine();189 List<RGB> _scan = this.scan(_builder);190 RGB _get = _scan.get(4);191 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.get(4) => LABEL but"192 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan.get(4) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()193 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()194 + "\n \'\'\'\n\t\tType name, label: /a/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()195 + "\n LABEL is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.LABEL).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.LABEL));196 197 }198 199 @Test200 @Named("parse reference")201 @Order(10)202 public void _parseReference() throws Exception {203 StringConcatenation _builder = new StringConcatenation();204 _builder.append("Type name, label: /long/a/Reference");205 _builder.newLine();206 List<RGB> _scan = this.scan(_builder);207 RGB _get = _scan.get(6);208 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: /long/a/Reference\n\t\t\'\'\'.scan.get(6) => REFERENCE but"209 + "\n \'\'\'\n\t\tType name, label: /long/a/Reference\n\t\t\'\'\'.scan.get(6) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()210 + "\n \'\'\'\n\t\tType name, label: /long/a/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()211 + "\n \'\'\'\n\t\tType name, label: /long/a/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()212 + "\n REFERENCE is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.REFERENCE).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.REFERENCE));213 214 }215 216 @Test217 @Named("parse macros")218 @Order(11)219 public void _parseMacros() throws Exception {220 StringConcatenation _builder = new StringConcatenation();221 _builder.append("Type name, label: <generic>");222 _builder.newLine();223 List<RGB> _scan = this.scan(_builder);224 RGB _get = _scan.get(6);225 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: <generic>\n\t\t\'\'\'.scan.get(6) => GENERICS but"226 + "\n \'\'\'\n\t\tType name, label: <generic>\n\t\t\'\'\'.scan.get(6) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()227 + "\n \'\'\'\n\t\tType name, label: <generic>\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()228 + "\n \'\'\'\n\t\tType name, label: <generic>\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()229 + "\n GENERICS is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.GENERICS).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.GENERICS));230 231 }232 233 @Test234 @Named("parse reference without leading \\\'/\\\'")235 @Order(12)236 public void _parseReferenceWithoutLeading() throws Exception {237 StringConcatenation _builder = new StringConcatenation();238 _builder.append("Type name, label: a/long/Reference");239 _builder.newLine();240 List<RGB> _scan = this.scan(_builder);241 RGB _get = _scan.get(6);242 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: a/long/Reference\n\t\t\'\'\'.scan.get(6) => REFERENCE but"243 + "\n \'\'\'\n\t\tType name, label: a/long/Reference\n\t\t\'\'\'.scan.get(6) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()244 + "\n \'\'\'\n\t\tType name, label: a/long/Reference\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()245 + "\n \'\'\'\n\t\tType name, label: a/long/Reference\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()246 + "\n REFERENCE is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.REFERENCE).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.REFERENCE));247 248 }249 250 @Test251 @Named("parse number")252 @Order(13)253 public void _parseNumber() throws Exception {254 StringConcatenation _builder = new StringConcatenation();255 _builder.append("Type name, label: 8");256 _builder.newLine();257 List<RGB> _scan = this.scan(_builder);258 RGB _get = _scan.get(6);259 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: 8\n\t\t\'\'\'.scan.get(6) => NUMBER but"260 + "\n \'\'\'\n\t\tType name, label: 8\n\t\t\'\'\'.scan.get(6) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()261 + "\n \'\'\'\n\t\tType name, label: 8\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()262 + "\n \'\'\'\n\t\tType name, label: 8\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()263 + "\n NUMBER is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.NUMBER).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.NUMBER));264 265 }266 267 @Test268 @Named("parse string")269 @Order(14)270 public void _parseString() throws Exception {271 StringConcatenation _builder = new StringConcatenation();272 _builder.append("Type name, label: \"a string\"");273 _builder.newLine();274 final List<RGB> string = this.scan(_builder);275 RGB _get = string.get(6);276 Assert.assertTrue("\nExpected string.get(6) => STRING but"277 + "\n string.get(6) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()278 + "\n string is " + new org.hamcrest.StringDescription().appendValue(string).toString()279 + "\n STRING is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.STRING).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.STRING));280 281 }282 283 @Test284 @Named("parse enum")285 @Order(15)286 public void _parseEnum() throws Exception {287 StringConcatenation _builder = new StringConcatenation();288 _builder.append("Type name, label: enum");289 _builder.newLine();290 List<RGB> _scan = this.scan(_builder);291 RGB _get = _scan.get(6);292 Assert.assertTrue("\nExpected \'\'\'\n\t\tType name, label: enum\n\t\t\'\'\'.scan.get(6) => IDENTIFIER but"293 + "\n \'\'\'\n\t\tType name, label: enum\n\t\t\'\'\'.scan.get(6) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()294 + "\n \'\'\'\n\t\tType name, label: enum\n\t\t\'\'\'.scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()295 + "\n \'\'\'\n\t\tType name, label: enum\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()296 + "\n IDENTIFIER is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.IDENTIFIER).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.IDENTIFIER));297 298 }299 300 @Test301 @Named("parse whitespace")302 @Order(16)303 public void _parseWhitespace() throws Exception {304 List<RGB> _scan = this.scan("Type name, label: enum\r\n");305 RGB _get = _scan.get(6);306 Assert.assertTrue("\nExpected \"Type name, label: enum\\r\\n\".scan.get(6) => IDENTIFIER but"307 + "\n \"Type name, label: enum\\r\\n\".scan.get(6) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()308 + "\n \"Type name, label: enum\\r\\n\".scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()309 + "\n IDENTIFIER is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.IDENTIFIER).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.IDENTIFIER));310 311 }312 313 @Test314 @Named("parse whitespace after command")315 @Order(17)316 public void _parseWhitespaceAfterCommand() throws Exception {317 final String input = "Type ";318 this.scan(input);319 int _tokenOffset = this.subject.getTokenOffset();320 int _tokenLength = this.subject.getTokenLength();321 int _plus = (_tokenOffset + _tokenLength);322 int _length = input.length();323 boolean _lessEqualsThan = (_plus <= _length);324 Assert.assertTrue("\nExpected subject.tokenOffset + subject.tokenLength <= input.length but"325 + "\n subject.tokenOffset + subject.tokenLength is " + new org.hamcrest.StringDescription().appendValue(_plus).toString()326 + "\n subject.tokenOffset is " + new org.hamcrest.StringDescription().appendValue(_tokenOffset).toString()327 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString()328 + "\n subject.tokenLength is " + new org.hamcrest.StringDescription().appendValue(_tokenLength).toString()329 + "\n input.length is " + new org.hamcrest.StringDescription().appendValue(_length).toString()330 + "\n input is " + new org.hamcrest.StringDescription().appendValue(input).toString() + "\n", _lessEqualsThan);331 332 }333 334 @Test335 @Named("parse string until EOL")336 @Order(18)337 public void _parseStringUntilEOL() throws Exception {338 List<RGB> _scan = this.scan(("Type name, label: \"a string " + Character.valueOf(AbstractRTextParser.EOL)));339 RGB _get = _scan.get(6);340 Assert.assertTrue("\nExpected (\'Type name, label: \"a string \' + EOL).scan.get(6) => STRING but"341 + "\n \'Type name, label: \"a string \' + EOL).scan.get(6 is " + new org.hamcrest.StringDescription().appendValue(_get).toString()342 + "\n (\'Type name, label: \"a string \' + EOL).scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()343 + "\n \'Type name, label: \"a string \' + EOL is " + new org.hamcrest.StringDescription().appendValue(("Type name, label: \"a string " + Character.valueOf(AbstractRTextParser.EOL))).toString()344 + "\n EOL is " + new org.hamcrest.StringDescription().appendValue(Character.valueOf(AbstractRTextParser.EOL)).toString()345 + "\n STRING is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.STRING).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.STRING));346 347 }348 349 @Test350 @Named("line breaks after comma")351 @Order(19)352 public void _lineBreaksAfterComma() throws Exception {353 StringConcatenation _builder = new StringConcatenation();354 _builder.append("Type name,");355 _builder.newLine();356 _builder.append("label: \"a string\"");357 _builder.newLine();358 List<RGB> _scan = this.scan(_builder);359 RGB _get = _scan.get(6);360 Assert.assertTrue("\nExpected (\'\'\'\n\t\tType name,\n\t\tlabel: \"a string\"\n\t\t\'\'\').scan.get(6) => STRING but"361 + "\n \'\'\'\n\t\tType name,\n\t\tlabel: \"a string\"\n\t\t\'\'\').scan.get(6 is " + new org.hamcrest.StringDescription().appendValue(_get).toString()362 + "\n (\'\'\'\n\t\tType name,\n\t\tlabel: \"a string\"\n\t\t\'\'\').scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()363 + "\n \'\'\'\n\t\tType name,\n\t\tlabel: \"a string\"\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()364 + "\n STRING is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.STRING).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.STRING));365 366 }367 368 @Test369 @Named("line breaks after \\\'\\\'")370 @Order(20)371 public void _lineBreaksAfter() throws Exception {372 StringConcatenation _builder = new StringConcatenation();373 _builder.append("Type name, label: \\ \"a string\"");374 _builder.newLine();375 List<RGB> _scan = this.scan(_builder);376 RGB _get = _scan.get(6);377 Assert.assertTrue("\nExpected (\'\'\'\n\t\tType name, label: \\ \"a string\"\n\t\t\'\'\').scan.get(6) => STRING but"378 + "\n \'\'\'\n\t\tType name, label: \\ \"a string\"\n\t\t\'\'\').scan.get(6 is " + new org.hamcrest.StringDescription().appendValue(_get).toString()379 + "\n (\'\'\'\n\t\tType name, label: \\ \"a string\"\n\t\t\'\'\').scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()380 + "\n \'\'\'\n\t\tType name, label: \\ \"a string\"\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()381 + "\n STRING is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.STRING).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.STRING));382 383 }384 385 @Test386 @Named("line breaks after backslash")387 @Order(21)388 public void _lineBreaksAfterBackslash() throws Exception {389 StringConcatenation _builder = new StringConcatenation();390 _builder.append("Type name, label: \\");391 _builder.newLine();392 _builder.append(" ");393 _builder.append("\"a string\"");394 _builder.newLine();395 List<RGB> _scan = this.scan(_builder);396 RGB _get = _scan.get(6);397 Assert.assertTrue("\nExpected (\'\'\'\n\t\tType name, label: \\\n\t\t \"a string\"\n\t\t\'\'\').scan.get(6) => STRING but"398 + "\n \'\'\'\n\t\tType name, label: \\\n\t\t \"a string\"\n\t\t\'\'\').scan.get(6 is " + new org.hamcrest.StringDescription().appendValue(_get).toString()399 + "\n (\'\'\'\n\t\tType name, label: \\\n\t\t \"a string\"\n\t\t\'\'\').scan is " + new org.hamcrest.StringDescription().appendValue(_scan).toString()400 + "\n \'\'\'\n\t\tType name, label: \\\n\t\t \"a string\"\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()401 + "\n STRING is " + new org.hamcrest.StringDescription().appendValue(IColorConstants.STRING).toString() + "\n", Should.<RGB>operator_doubleArrow(_get, IColorConstants.STRING));402 403 }404 405 @Test406 @Named("positions macros correctly")407 @Order(22)408 public void _positionsMacrosCorrectly() throws Exception {409 StringConcatenation _builder = new StringConcatenation();410 _builder.append("EPackage{");411 _builder.newLine();412 _builder.append("\t");413 _builder.append("EClass{");414 _builder.newLine();415 _builder.append("\t\t");416 _builder.append("EOperation{");417 _builder.newLine();418 _builder.append("\t\t\t");419 _builder.append("EAnnotation source:<source> ");420 _builder.newLine();421 _builder.append("\t\t");422 _builder.append("}");423 _builder.newLine();424 _builder.append("\t");425 _builder.append("}");426 _builder.newLine();427 _builder.append("}\t");428 _builder.newLine();429 _builder.newLine();430 List<String> _regions = this.regions(_builder);431 String _get = _regions.get(12);432 Assert.assertTrue("\nExpected \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<source> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\'.regions.get(12) => \"<source>\" but"433 + "\n \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<source> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\'.regions.get(12) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()434 + "\n \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<source> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\'.regions is " + new org.hamcrest.StringDescription().appendValue(_regions).toString()435 + "\n \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<source> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString() + "\n", Should.<String>operator_doubleArrow(_get, "<source>"));436 437 }438 439 @Test440 @Named("support escaped macros")441 @Order(23)442 public void _supportEscapedMacros() throws Exception {443 StringConcatenation _builder = new StringConcatenation();444 _builder.append("EPackage{");445 _builder.newLine();446 _builder.append("\t");447 _builder.append("EClass{");448 _builder.newLine();449 _builder.append("\t\t");450 _builder.append("EOperation{");451 _builder.newLine();452 _builder.append("\t\t\t");453 _builder.append("EAnnotation source:<%text>text%> ");454 _builder.newLine();455 _builder.append("\t\t");456 _builder.append("}");457 _builder.newLine();458 _builder.append("\t");459 _builder.append("}");460 _builder.newLine();461 _builder.append("}\t");462 _builder.newLine();463 _builder.newLine();464 List<String> _regions = this.regions(_builder);465 String _get = _regions.get(12);466 Assert.assertTrue("\nExpected \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<%text>text%> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\'.regions.get(12) => \"<%text>text%>\" but"467 + "\n \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<%text>text%> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\'.regions.get(12) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()468 + "\n \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<%text>text%> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\'.regions is " + new org.hamcrest.StringDescription().appendValue(_regions).toString()469 + "\n \'\'\'\n\t\tEPackage{\n\t\t\tEClass{\n\t\t\t\tEOperation{\n\t\t\t\t\tEAnnotation source:<%text>text%> \n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\n\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString() + "\n", Should.<String>operator_doubleArrow(_get, "<%text>text%>"));470 471 }472 473 @Test474 @Named("support escaped macros without end")475 @Order(24)476 public void _supportEscapedMacrosWithoutEnd() throws Exception {477 StringConcatenation _builder = new StringConcatenation();478 _builder.append("EPackage{");479 _builder.newLine();480 _builder.append("\t");481 _builder.append("EClass{");482 _builder.newLine();483 _builder.append("\t\t");484 _builder.append("EOperation{");485 _builder.newLine();486 _builder.append("\t\t\t");487 _builder.append("EAnnotation source:<%text>text");488 List<String> _regions = this.regions(_builder);489 final String region = _regions.get(12);490 Assert.assertTrue("\nExpected region => \"<%text>text\" but"491 + "\n region is " + new org.hamcrest.StringDescription().appendValue(region).toString() + "\n", Should.<String>operator_doubleArrow(region, "<%text>text"));492 493 }494 495 public List<RGB> incrementalScan(final CharSequence s) {496 final String text = s.toString();497 final int offset = text.indexOf("|");498 String _replace = text.replace("|", "");499 final SimpleDocument document = new SimpleDocument(_replace);500 int _length = s.length();501 this.subject.setRange(document, offset, _length);502 return this.tokens();503 }504 505 public List<String> regions(final CharSequence s) {506 List<String> _xblockexpression = null;507 {508 String _string = s.toString();509 final SimpleDocument document = new SimpleDocument(_string);510 int _length = s.length();511 this.subject.setRange(document, 0, _length);512 final List<String> regions = JnarioCollectionLiterals.<String>list();513 IToken token = this.subject.nextToken();514 while ((!token.isEOF())) {515 {516 int _tokenOffset = this.subject.getTokenOffset();517 int _tokenLength = this.subject.getTokenLength();518 String _get = document.get(_tokenOffset, _tokenLength);519 regions.add(_get);520 IToken _nextToken = this.subject.nextToken();521 token = _nextToken;522 }523 }524 _xblockexpression = regions;525 }526 return _xblockexpression;527 }528 529 public List<RGB> scan(final CharSequence s) {530 String _string = s.toString();531 final SimpleDocument document = new SimpleDocument(_string);532 int _length = s.length();533 this.subject.setRange(document, 0, _length);534 return this.tokens();535 }536 537 public List<RGB> tokens() {538 List<RGB> _xblockexpression = null;539 {540 final List<IToken> tokens = JnarioCollectionLiterals.<IToken>list();541 IToken token = this.subject.nextToken();542 while ((!token.isEOF())) {543 {544 tokens.add(token);...
Source:UsingShouldSpec.java
...45 public void _toPass() throws Exception {46 boolean _should_be = Should.<Boolean>should_be(47 Boolean.valueOf(true), true);48 Assert.assertTrue("\nExpected // equality\r\n true should be true but"49 + "\n // equality\r\n true should be true is " + new org.hamcrest.StringDescription().appendValue(true).toString() + "\n", _should_be);50 51 boolean _should_be_1 = Should.<Integer>should_be(52 Integer.valueOf((1 + 1)), Integer.valueOf(1));53 Assert.assertFalse("\nExpected 1 + 1 should not be 1 but"54 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString() + "\n", _should_be_1);55 56 Assert.assertNotNull("\nExpected \"something\" should not be null\n but is " + new org.hamcrest.StringDescription().appendValue("something").toString() + "\n", "something");57 58 boolean _doubleArrow = Should.<Integer>operator_doubleArrow(59 Integer.valueOf((1 + 1)), Integer.valueOf(2));60 Assert.assertTrue("\nExpected 1 + 1 => 2 but"61 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString() + "\n", _doubleArrow);62 63 boolean _doubleArrow_1 = Should.operator_doubleArrow(64 "a string", String.class);65 Assert.assertTrue("\nExpected // types\r\n \"a string\" => typeof(String) but"66 + "\n // types\r\n \"a string\" => typeof(String) is " + new org.hamcrest.StringDescription().appendValue(_doubleArrow_1).toString() + "\n", _doubleArrow_1);67 68 Class<? extends String> _class = "a string".getClass();69 boolean _doubleArrow_2 = Should.operator_doubleArrow(_class, String.class);70 Assert.assertTrue("\nExpected \"a string\".getClass => typeof(String) but"71 + "\n \"a string\".getClass is " + new org.hamcrest.StringDescription().appendValue(_class).toString() + "\n", _doubleArrow_2);72 73 boolean _should_contain = Should.<Object>should_contain(74 "something", "thing");75 Assert.assertTrue("\nExpected // strings\r\n \"something\" should contain \"thing\" but"76 + "\n // strings\r\n \"something\" should contain \"thing\" is " + new org.hamcrest.StringDescription().appendValue(true).toString() + "\n", _should_contain);77 78 boolean _should_contain_1 = Should.<Object>should_contain(79 "something", "any");80 Assert.assertFalse("\nExpected \"something\" should not contain \"any\" but"81 + "\n \"something\" should not contain \"any\" is " + new org.hamcrest.StringDescription().appendValue(true).toString() + "\n", _should_contain_1);82 83 List<String> _list = JnarioCollectionLiterals.<String>list("something");84 boolean _should_contain_2 = Should.<String>should_contain(_list, "something");85 Assert.assertTrue("\nExpected // iterables\r\n list(\"something\") should contain \"something\" but"86 + "\n // iterables\r\n list(\"something\") is " + new org.hamcrest.StringDescription().appendValue(_list).toString() + "\n", _should_contain_2);87 88 List<String> _list_1 = JnarioCollectionLiterals.<String>list("something");89 boolean _should_contain_3 = Should.<String>should_contain(_list_1, "something else");90 Assert.assertFalse("\nExpected list(\"something\") should not contain \"something else\" but"91 + "\n list(\"something\") is " + new org.hamcrest.StringDescription().appendValue(_list_1).toString() + "\n", _should_contain_3);92 93 final Procedure1<String> _function = new Procedure1<String>() {94 public void apply(final String it) {95 int _length = it.length();96 boolean _doubleArrow = Should.<Integer>operator_doubleArrow(Integer.valueOf(_length), Integer.valueOf(11));97 Assert.assertTrue("\nExpected length => 11 but"98 + "\n length is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_length)).toString() + "\n", _doubleArrow);99 100 boolean _should_startWith = Should.should_startWith(it, "hello");101 Assert.assertTrue("\nExpected it should startWith(\"hello\") but"102 + "\n it is " + new org.hamcrest.StringDescription().appendValue(it).toString() + "\n", _should_startWith);103 104 Assert.assertTrue("\nExpected it should endWith(\"world\") but"105 + "\n it is " + new org.hamcrest.StringDescription().appendValue(it).toString() + "\n", Should.should_endWith(it, "world"));106 107 }108 };109 final String greeting = ObjectExtensions.<String>operator_doubleArrow("hello world", _function);110 boolean _doubleArrow_3 = Should.operator_doubleArrow(greeting, String.class);111 Assert.assertTrue("\nExpected greeting => typeof(String) but"112 + "\n greeting is " + new org.hamcrest.StringDescription().appendValue(greeting).toString() + "\n", _doubleArrow_3);113 114 boolean expectedException = false;115 String message = "";116 try{117 Stack<String> _stack = new Stack<String>();118 _stack.pop();119 message = "Expected " + EmptyStackException.class.getName() + " for \n // expecting exceptions\r\n new Stack<String>().pop\n with:"120 + "\n // expecting exceptions\r\n new Stack<String>() is " + new org.hamcrest.StringDescription().appendValue(_stack).toString();121 }catch(EmptyStackException e){122 expectedException = true;123 }124 Assert.assertTrue(message, expectedException);125 boolean expectedException_1 = false;126 String message_1 = "";127 try{128 Stack<String> _stack_1 = new Stack<String>();129 _stack_1.pop();130 message_1 = "Expected " + EmptyStackException.class.getName() + " for \n new Stack<String>().pop\n with:"131 + "\n new Stack<String>() is " + new org.hamcrest.StringDescription().appendValue(_stack_1).toString();132 }catch(EmptyStackException e){133 expectedException_1 = true;134 }135 Assert.assertTrue(message_1, expectedException_1);136 }137 138 /**139 * `should` throws an AssertionError if the result of the left140 * expression does not equal the result of the right expression.141 * Here is a helper method we are going to use:142 * 143 * <pre class="prettyprint lang-spec">144 * def void method(){145 * throw new IllegalArgumentException146 * }147 * </pre>148 * 149 * ...and here are the examples:150 */151 @Test152 @Named("...or not to pass")153 @Order(2)154 public void _orNotToPass() throws Exception {155 boolean expectedException = false;156 String message = "";157 try{158 boolean _should_be = Should.<Integer>should_be(159 Integer.valueOf((1 + 1)), Integer.valueOf(1));160 Assert.assertTrue("\nExpected 1 + 1 should be 1 but"161 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString() + "\n", _should_be);162 163 message = "Expected " + AssertionError.class.getName() + " for \n 1 + 1 should be 1\n with:"164 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString();165 }catch(AssertionError e){166 expectedException = true;167 }168 Assert.assertTrue(message, expectedException);169 boolean expectedException_1 = false;170 String message_1 = "";171 try{172 boolean _should_be_1 = Should.<Integer>should_be(173 Integer.valueOf((1 + 1)), Integer.valueOf(2));174 Assert.assertFalse("\nExpected 1 + 1 should not be 2 but"175 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString() + "\n", _should_be_1);176 177 message_1 = "Expected " + AssertionError.class.getName() + " for \n 1 + 1 should not be 2\n with:"178 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString();179 }catch(AssertionError e){180 expectedException_1 = true;181 }182 Assert.assertTrue(message_1, expectedException_1);183 boolean expectedException_2 = false;184 String message_2 = "";185 try{186 boolean _doubleArrow = Should.<Integer>operator_doubleArrow(187 Integer.valueOf((1 + 1)), Integer.valueOf(1));188 Assert.assertTrue("\nExpected 1 + 1 => 1 but"189 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString() + "\n", _doubleArrow);190 191 message_2 = "Expected " + AssertionError.class.getName() + " for \n 1 + 1 => 1\n with:"192 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString();193 }catch(AssertionError e){194 expectedException_2 = true;195 }196 Assert.assertTrue(message_2, expectedException_2);197 boolean expectedException_3 = false;198 String message_3 = "";199 try{200 Object _object = new Object();201 Assert.assertNull("\nExpected new Object => null\n but is " + new org.hamcrest.StringDescription().appendValue(_object).toString() + "\n", _object);202 203 message_3 = "Expected " + AssertionError.class.getName() + " for \n new Object => null\n with:"204 + "\n new Object is " + new org.hamcrest.StringDescription().appendValue(_object).toString();205 }catch(AssertionError e){206 expectedException_3 = true;207 }208 Assert.assertTrue(message_3, expectedException_3);209 boolean expectedException_4 = false;210 String message_4 = "";211 try{212 Object _object_1 = new Object();213 Assert.assertNull("\nExpected new Object should be null\n but is " + new org.hamcrest.StringDescription().appendValue(_object_1).toString() + "\n", _object_1);214 215 message_4 = "Expected " + AssertionError.class.getName() + " for \n new Object should be null\n with:"216 + "\n new Object is " + new org.hamcrest.StringDescription().appendValue(_object_1).toString();217 }catch(AssertionError e){218 expectedException_4 = true;219 }220 Assert.assertTrue(message_4, expectedException_4);221 boolean expectedException_5 = false;222 String message_5 = "";223 try{224 this.method();225 message_5 = "Expected " + IllegalArgumentException.class.getName() + " for \n method()\n with:";226 }catch(IllegalArgumentException e){227 expectedException_5 = true;228 }229 Assert.assertTrue(message_5, expectedException_5);230 }231 232 public void method() {233 throw new IllegalArgumentException();234 }235 236 /**237 * When failing, `should` and `=>` try to give you as much context information as possible.238 * The error message will print the values of all expressions and their subexpressions.239 */240 @Test241 @Named("Why did it fail?")242 @Order(3)243 public void _whyDidItFail() throws Exception {244 final Procedure1<Boolean> _function = new Procedure1<Boolean>() {245 public void apply(final Boolean it) {246 Assert.assertTrue("\nExpected 1 + 1 => 1 but"247 + "\n 1 + 1 is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf((1 + 1))).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf((1 + 1)), Integer.valueOf(1)));248 249 }250 };251 String _errorMessage = Helpers.errorMessage(_function);252 StringConcatenation _builder = new StringConcatenation();253 _builder.append("Expected 1 + 1 => 1 but");254 _builder.newLine();255 _builder.append(" ");256 _builder.append("1 + 1 is <2>");257 Helpers.is(_errorMessage, _builder);258 final String x = "hello";259 final Procedure1<Boolean> _function_1 = new Procedure1<Boolean>() {260 public void apply(final Boolean it) {261 String _upperCase = x.toUpperCase();262 Assert.assertFalse("\nExpected x.toUpperCase should not be \"HELLO\" but"263 + "\n x.toUpperCase is " + new org.hamcrest.StringDescription().appendValue(_upperCase).toString()264 + "\n x is " + new org.hamcrest.StringDescription().appendValue(x).toString() + "\n", Should.<String>should_be(_upperCase, "HELLO"));265 266 }267 };268 String _errorMessage_1 = Helpers.errorMessage(_function_1);269 StringConcatenation _builder_1 = new StringConcatenation();270 _builder_1.append("Expected x.toUpperCase should not be \"HELLO\" but");271 _builder_1.newLine();272 _builder_1.append(" ");273 _builder_1.append("x.toUpperCase is \"HELLO\"");274 _builder_1.newLine();275 _builder_1.append(" ");276 _builder_1.append("x is \"hello\"");277 Helpers.is(_errorMessage_1, _builder_1);278 final String y = "world";279 final Procedure1<Boolean> _function_2 = new Procedure1<Boolean>() {280 public void apply(final Boolean it) {281 Assert.assertTrue("\nExpected x => y but"282 + "\n x is " + new org.hamcrest.StringDescription().appendValue(x).toString()283 + "\n y is " + new org.hamcrest.StringDescription().appendValue(y).toString() + "\n", Should.<String>operator_doubleArrow(x, y));284 285 }286 };287 String _errorMessage_2 = Helpers.errorMessage(_function_2);288 StringConcatenation _builder_2 = new StringConcatenation();289 _builder_2.append("Expected x => y but");290 _builder_2.newLine();291 _builder_2.append(" ");292 _builder_2.append("x is \"hello\"");293 _builder_2.newLine();294 _builder_2.append(" ");295 _builder_2.append("y is \"world\"");296 Helpers.is(_errorMessage_2, _builder_2);297 }298 299 /**300 * This useful helper automatically waits until a condition turns true.301 * Expects a lambda expression returning a boolean value. The error message,302 * polling interval and duration are configurable.303 */304 @Test305 @Named("Wait for something")306 @Order(4)307 public void _waitForSomething() throws Exception {308 final Function1<Wait, Boolean> _function = new Function1<Wait, Boolean>() {309 public Boolean apply(final Wait it) {310 return Boolean.valueOf((1 > 0));311 }312 };313 Wait.waitUntil(_function);314 final Function1<Wait, Boolean> _function_1 = new Function1<Wait, Boolean>() {315 public Boolean apply(final Wait it) {316 boolean _xblockexpression = false;317 {318 it.setMessage("Custom error message");319 it.setDuration(100);320 it.setPollingInterval(10);321 _xblockexpression = (1 > 0);322 }323 return Boolean.valueOf(_xblockexpression);324 }325 };326 Wait.waitUntil(_function_1);327 }328 329 /**330 * You can also define your own *should* matchers by331 * defining a method with the prefix *should_XXXX* in332 * the current scope. The method needs to return a boolean333 * value. For example, when we define334 * a method *should_eat*:335 * 336 * def should_eat(String animal, String food){337 * animal == "Monkey" && food == "Banana"338 * }339 * 340 * We can use "eat" in our should expressions:341 */342 @Test343 @Named("Define your own matchers")344 @Order(5)345 public void _defineYourOwnMatchers() throws Exception {346 boolean _should_eat = this.should_eat(347 "Monkey", "Banana");348 Assert.assertTrue("\nExpected \"Monkey\" should eat \"Banana\" but" + " did not." + "\n", _should_eat);349 350 boolean expectedException = false;351 String message = "";352 try{353 boolean _should_eat_1 = this.should_eat(354 "Monkey", "Rocks");355 Assert.assertTrue("\nExpected \"Monkey\" should eat \"Rocks\" but" + " did not." + "\n", _should_eat_1);356 357 message = "Expected " + AssertionError.class.getName() + " for \n \"Monkey\" should eat \"Rocks\"\n with:";358 }catch(AssertionError e){359 expectedException = true;360 }361 Assert.assertTrue(message, expectedException);362 }363 364 public boolean should_eat(final String animal, final String food) {365 boolean _and = false;366 boolean _equals = Objects.equal(animal, "Monkey");367 if (!_equals) {368 _and = false;369 } else {370 boolean _equals_1 = Objects.equal(food, "Banana");371 _and = _equals_1;372 }373 return _and;374 }375 376 /**377 * You can also the `should` and `=>` together with [hamcrest](http://code.google.com/p/hamcrest/)378 * matchers. The following static import statements are needed to run the examples:379 * 380 * import static org.hamcrest.CoreMatchers.startsWith381 * import static org.hamcrest.CoreMatchers.equalTo382 * 383 * If the right-hand side of a should expression is a matcher, the matcher will be evaluated instead384 * of testing for equality:385 */386 @Test387 @Named("Combining hamcrest and should")388 @Order(6)389 public void _combiningHamcrestAndShould() throws Exception {390 Matcher<String> _startsWith = Matchers.startsWith("h");391 boolean _doubleArrow = Should.<String>operator_doubleArrow(392 "hello", _startsWith);393 Assert.assertTrue("\nExpected \"hello\" => startsWith(\"h\") but"394 + "\n startsWith(\"h\") is " + new org.hamcrest.StringDescription().appendValue(_startsWith).toString() + "\n", _doubleArrow);395 396 Matcher<Integer> _greaterThan = Matchers.<Integer>greaterThan(Integer.valueOf(5));397 Assert.assertTrue("\nExpected 9 should be greaterThan(5) but"398 + "\n greaterThan(5) is " + new org.hamcrest.StringDescription().appendValue(_greaterThan).toString() + "\n", Should.<Integer>should_be(399 Integer.valueOf(9), _greaterThan));400 401 }402 403 /**404 * In order to be able to print the value of all subexpressions when an assertion failed,405 * we disabled the short circuit semantics of '&&' and '||' within assertions.406 */407 @Test408 @Named("Short Circuit Invocation")409 @Order(7)410 public void _shortCircuitInvocation() throws Exception {411 final String aString = null;412 boolean expectedException = false;413 String message = "";414 try{415 boolean _notEquals = (!Objects.equal(aString, null));416 int _length = aString.length();417 boolean _equals = (_length == 0);418 boolean _and = (_notEquals && _equals);419 Assert.assertTrue("\nExpected aString != null && aString.length == 0 but"420 + "\n aString != null is " + new org.hamcrest.StringDescription().appendValue(_notEquals).toString()421 + "\n aString is " + new org.hamcrest.StringDescription().appendValue(aString).toString()422 + "\n aString.length == 0 is " + new org.hamcrest.StringDescription().appendValue(_equals).toString()423 + "\n aString.length is " + new org.hamcrest.StringDescription().appendValue(_length).toString() + "\n", _and);424 425 message = "Expected " + NullPointerException.class.getName() + " for \n assert aString != null && aString.length == 0\n with:"426 + "\n aString != null && aString.length == 0 is " + new org.hamcrest.StringDescription().appendValue(_and).toString()427 + "\n aString != null is " + new org.hamcrest.StringDescription().appendValue(_notEquals).toString()428 + "\n aString is " + new org.hamcrest.StringDescription().appendValue(aString).toString()429 + "\n aString.length == 0 is " + new org.hamcrest.StringDescription().appendValue(_equals).toString()430 + "\n aString.length is " + new org.hamcrest.StringDescription().appendValue(_length).toString();431 }catch(NullPointerException e){432 expectedException = true;433 }434 Assert.assertTrue(message, expectedException);435 }436}...
Source:RTextModelParserStructureSpec.java
...31 Element _first = JnarioIterableExtensions.<Element>first(_parse);32 IsElement _element = IsElement.element("Type");33 boolean _doubleArrow = Should.<Element>operator_doubleArrow(_first, _element);34 Assert.assertTrue("\nExpected \"Type\".parse.first \t\t\t=> element(\"Type\") but"35 + "\n \"Type\".parse.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()36 + "\n \"Type\".parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()37 + "\n element(\"Type\") is " + new org.hamcrest.StringDescription().appendValue(_element).toString() + "\n", _doubleArrow);38 39 List<Element> _parse_1 = this.parse("OtherType");40 Element _first_1 = JnarioIterableExtensions.<Element>first(_parse_1);41 IsElement _element_1 = IsElement.element("OtherType");42 Assert.assertTrue("\nExpected \"OtherType\".parse.first\t\t=> element(\"OtherType\") but"43 + "\n \"OtherType\".parse.first is " + new org.hamcrest.StringDescription().appendValue(_first_1).toString()44 + "\n \"OtherType\".parse is " + new org.hamcrest.StringDescription().appendValue(_parse_1).toString()45 + "\n element(\"OtherType\") is " + new org.hamcrest.StringDescription().appendValue(_element_1).toString() + "\n", Should.<Element>operator_doubleArrow(_first_1, _element_1));46 47 }48 49 @Test50 @Named("parse command with annotation")51 @Order(2)52 public void _parseCommandWithAnnotation() throws Exception {53 List<Element> _parse = this.parse("@file-extension: ecuconfig\nType");54 Element _first = JnarioIterableExtensions.<Element>first(_parse);55 IsElement _element = IsElement.element("Type");56 Assert.assertTrue("\nExpected \"@file-extension: ecuconfig\\nType\".parse.first \t\t\t=> element(\"Type\") but"57 + "\n \"@file-extension: ecuconfig\\nType\".parse.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()58 + "\n \"@file-extension: ecuconfig\\nType\".parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()59 + "\n element(\"Type\") is " + new org.hamcrest.StringDescription().appendValue(_element).toString() + "\n", Should.<Element>operator_doubleArrow(_first, _element));60 61 }62 63 @Test64 @Named("parse multiple root elements")65 @Order(3)66 public void _parseMultipleRootElements() throws Exception {67 StringConcatenation _builder = new StringConcatenation();68 _builder.append("Root1");69 _builder.newLine();70 _builder.append("Root2");71 _builder.newLine();72 List<Element> _parse = this.parse(_builder);73 int _size = _parse.size();74 Assert.assertTrue("\nExpected \'\'\'\n\t\t\tRoot1\n\t\t\tRoot2\n\t\t\t\'\'\'.parse.size => 2 but"75 + "\n \'\'\'\n\t\t\tRoot1\n\t\t\tRoot2\n\t\t\t\'\'\'.parse.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()76 + "\n \'\'\'\n\t\t\tRoot1\n\t\t\tRoot2\n\t\t\t\'\'\'.parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()77 + "\n \'\'\'\n\t\t\tRoot1\n\t\t\tRoot2\n\t\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(2)));78 79 }80 81 @Test82 @Named("correctly sets offset of last element")83 @Order(4)84 public void _correctlySetsOffsetOfLastElement() throws Exception {85 StringConcatenation _builder = new StringConcatenation();86 _builder.append("Root1");87 _builder.newLine();88 _builder.append("Root2");89 _builder.newLine();90 _builder.newLine();91 final String input = _builder.toString();92 List<Element> _parse = this.parse(input);93 int _size = _parse.size();94 Assert.assertTrue("\nExpected input.parse.size => 2 but"95 + "\n input.parse.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()96 + "\n input.parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()97 + "\n input is " + new org.hamcrest.StringDescription().appendValue(input).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(2)));98 99 }100 101 @Test102 @Named("parse name")103 @Order(5)104 public void _parseName() throws Exception {105 List<Element> _parse = this.parse("Type name1");106 Element _first = JnarioIterableExtensions.<Element>first(_parse);107 IsElement _element = IsElement.element("Type", "name1");108 boolean _doubleArrow = Should.<Element>operator_doubleArrow(_first, _element);109 Assert.assertTrue("\nExpected \"Type name1\".parse.first \t\t\t\t\t=> element(\"Type\", \"name1\") but"110 + "\n \"Type name1\".parse.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()111 + "\n \"Type name1\".parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()112 + "\n element(\"Type\", \"name1\") is " + new org.hamcrest.StringDescription().appendValue(_element).toString() + "\n", _doubleArrow);113 114 List<Element> _parse_1 = this.parse("OtherType name2");115 Element _first_1 = JnarioIterableExtensions.<Element>first(_parse_1);116 IsElement _element_1 = IsElement.element("OtherType", "name2");117 boolean _doubleArrow_1 = Should.<Element>operator_doubleArrow(_first_1, _element_1);118 Assert.assertTrue("\nExpected \"OtherType name2\".parse.first \t\t\t\t=> element(\"OtherType\", \"name2\") but"119 + "\n \"OtherType name2\".parse.first is " + new org.hamcrest.StringDescription().appendValue(_first_1).toString()120 + "\n \"OtherType name2\".parse is " + new org.hamcrest.StringDescription().appendValue(_parse_1).toString()121 + "\n element(\"OtherType\", \"name2\") is " + new org.hamcrest.StringDescription().appendValue(_element_1).toString() + "\n", _doubleArrow_1);122 123 List<Element> _parse_2 = this.parse("Type name3 label: something");124 Element _first_2 = JnarioIterableExtensions.<Element>first(_parse_2);125 IsElement _element_2 = IsElement.element("Type", "name3");126 Assert.assertTrue("\nExpected \"Type name3 label: something\".parse.first \t=> element(\"Type\", \"name3\") but"127 + "\n \"Type name3 label: something\".parse.first is " + new org.hamcrest.StringDescription().appendValue(_first_2).toString()128 + "\n \"Type name3 label: something\".parse is " + new org.hamcrest.StringDescription().appendValue(_parse_2).toString()129 + "\n element(\"Type\", \"name3\") is " + new org.hamcrest.StringDescription().appendValue(_element_2).toString() + "\n", Should.<Element>operator_doubleArrow(_first_2, _element_2));130 131 }132 133 @Test134 @Named("parse attributes")135 @Order(6)136 public void _parseAttributes() throws Exception {137 List<Element> _parse = this.parse("Type name1, label: 10");138 Element _first = JnarioIterableExtensions.<Element>first(_parse);139 IsElement _element = IsElement.element("Type", "name1");140 boolean _doubleArrow = Should.<Element>operator_doubleArrow(_first, _element);141 Assert.assertTrue("\nExpected \"Type name1, label: 10\".parse.first => \telement(\"Type\", \"name1\") but"142 + "\n \"Type name1, label: 10\".parse.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()143 + "\n \"Type name1, label: 10\".parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()144 + "\n element(\"Type\", \"name1\") is " + new org.hamcrest.StringDescription().appendValue(_element).toString() + "\n", _doubleArrow);145 146 List<Element> _parse_1 = this.parse("Type name1, label: \"a string\"");147 Element _first_1 = JnarioIterableExtensions.<Element>first(_parse_1);148 IsElement _element_1 = IsElement.element("Type", "name1");149 boolean _doubleArrow_1 = Should.<Element>operator_doubleArrow(_first_1, _element_1);150 Assert.assertTrue("\nExpected \'Type name1, label: \"a string\"\'.parse.first => \telement(\"Type\", \"name1\") but"151 + "\n \'Type name1, label: \"a string\"\'.parse.first is " + new org.hamcrest.StringDescription().appendValue(_first_1).toString()152 + "\n \'Type name1, label: \"a string\"\'.parse is " + new org.hamcrest.StringDescription().appendValue(_parse_1).toString()153 + "\n element(\"Type\", \"name1\") is " + new org.hamcrest.StringDescription().appendValue(_element_1).toString() + "\n", _doubleArrow_1);154 155 List<Element> _parse_2 = this.parse("Type name1, label: /a/reference");156 Element _first_2 = JnarioIterableExtensions.<Element>first(_parse_2);157 IsElement _element_2 = IsElement.element("Type", "name1");158 Assert.assertTrue("\nExpected \'Type name1, label: /a/reference\'.parse.first => element(\"Type\", \"name1\") but"159 + "\n \'Type name1, label: /a/reference\'.parse.first is " + new org.hamcrest.StringDescription().appendValue(_first_2).toString()160 + "\n \'Type name1, label: /a/reference\'.parse is " + new org.hamcrest.StringDescription().appendValue(_parse_2).toString()161 + "\n element(\"Type\", \"name1\") is " + new org.hamcrest.StringDescription().appendValue(_element_2).toString() + "\n", Should.<Element>operator_doubleArrow(_first_2, _element_2));162 163 }164 165 @Test166 @Named("ignores comments")167 @Order(7)168 public void _ignoresComments() throws Exception {169 StringConcatenation _builder = new StringConcatenation();170 _builder.append("# a comment");171 _builder.newLine();172 _builder.append("Type");173 List<Element> _parse = this.parse(_builder);174 int _size = _parse.size();175 Assert.assertTrue("\nExpected \'\'\'\n\t\t\t# a comment\n\t\t\tType\'\'\'.parse.size => 1 but"176 + "\n \'\'\'\n\t\t\t# a comment\n\t\t\tType\'\'\'.parse.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()177 + "\n \'\'\'\n\t\t\t# a comment\n\t\t\tType\'\'\'.parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()178 + "\n \'\'\'\n\t\t\t# a comment\n\t\t\tType\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(1)));179 180 }181 182 @Test183 @Named("nests list")184 @Order(8)185 public void _nestsList() throws Exception {186 StringConcatenation _builder = new StringConcatenation();187 _builder.append("Type parent{");188 _builder.newLine();189 _builder.append("\t");190 _builder.append("Child child1{");191 _builder.newLine();192 _builder.append("\t");193 _builder.append("}");194 _builder.newLine();195 _builder.append("\t");196 _builder.append("Child child2{");197 _builder.newLine();198 _builder.append("\t");199 _builder.append("}");200 _builder.newLine();201 _builder.append("}");202 _builder.newLine();203 List<Element> _parse = this.parse(_builder);204 Element _first = JnarioIterableExtensions.<Element>first(_parse);205 IsElement _element = IsElement.element("Child", "child1");206 IsElement _element_1 = IsElement.element("Child", "child2");207 IsElement _element_2 = IsElement.element("Type", "parent", _element, _element_1);208 Assert.assertTrue("\nExpected \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1{\n\t\t\t\t}\n\t\t\t\tChild child2{\n\t\t\t\t}\n\t\t\t}\n\t\t\t\'\'\'.parse.first => \n\t\t\t\telement(\"Type\", \"parent\", \n\t\t\t\t\telement(\"Child\", \"child1\"),\n\t\t\t\t\telement(\"Child\", \"child2\")\n\t\t\t\t) but"209 + "\n \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1{\n\t\t\t\t}\n\t\t\t\tChild child2{\n\t\t\t\t}\n\t\t\t}\n\t\t\t\'\'\'.parse.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()210 + "\n \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1{\n\t\t\t\t}\n\t\t\t\tChild child2{\n\t\t\t\t}\n\t\t\t}\n\t\t\t\'\'\'.parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()211 + "\n \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1{\n\t\t\t\t}\n\t\t\t\tChild child2{\n\t\t\t\t}\n\t\t\t}\n\t\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()212 + "\n element(\"Type\", \"parent\", \n\t\t\t\t\telement(\"Child\", \"child1\"),\n\t\t\t\t\telement(\"Child\", \"child2\")\n\t\t\t\t) is " + new org.hamcrest.StringDescription().appendValue(_element_2).toString()213 + "\n element(\"Child\", \"child1\") is " + new org.hamcrest.StringDescription().appendValue(_element).toString()214 + "\n element(\"Child\", \"child2\") is " + new org.hamcrest.StringDescription().appendValue(_element_1).toString() + "\n", Should.<Element>operator_doubleArrow(_first, _element_2));215 216 }217 218 @Test219 @Named("nests list without curly braces")220 @Order(9)221 public void _nestsListWithoutCurlyBraces() throws Exception {222 StringConcatenation _builder = new StringConcatenation();223 _builder.append("Type parent{");224 _builder.newLine();225 _builder.append("\t");226 _builder.append("Child child1");227 _builder.newLine();228 _builder.append("\t");229 _builder.append("Child child2");230 _builder.newLine();231 _builder.append("}");232 _builder.newLine();233 List<Element> _parse = this.parse(_builder);234 Element _first = JnarioIterableExtensions.<Element>first(_parse);235 IsElement _element = IsElement.element("Child", "child1");236 IsElement _element_1 = IsElement.element("Child", "child2");237 IsElement _element_2 = IsElement.element("Type", "parent", _element, _element_1);238 Assert.assertTrue("\nExpected \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1\n\t\t\t\tChild child2\n\t\t\t}\n\t\t\t\'\'\'.parse.first => \n\t\t\t\telement(\"Type\", \"parent\", \n\t\t\t\t\telement(\"Child\", \"child1\"),\n\t\t\t\t\telement(\"Child\", \"child2\")\n\t\t\t\t) but"239 + "\n \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1\n\t\t\t\tChild child2\n\t\t\t}\n\t\t\t\'\'\'.parse.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()240 + "\n \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1\n\t\t\t\tChild child2\n\t\t\t}\n\t\t\t\'\'\'.parse is " + new org.hamcrest.StringDescription().appendValue(_parse).toString()241 + "\n \'\'\'\n\t\t\tType parent{\n\t\t\t\tChild child1\n\t\t\t\tChild child2\n\t\t\t}\n\t\t\t\'\'\' is " + new org.hamcrest.StringDescription().appendValue(_builder).toString()242 + "\n element(\"Type\", \"parent\", \n\t\t\t\t\telement(\"Child\", \"child1\"),\n\t\t\t\t\telement(\"Child\", \"child2\")\n\t\t\t\t) is " + new org.hamcrest.StringDescription().appendValue(_element_2).toString()243 + "\n element(\"Child\", \"child1\") is " + new org.hamcrest.StringDescription().appendValue(_element).toString()244 + "\n element(\"Child\", \"child2\") is " + new org.hamcrest.StringDescription().appendValue(_element_1).toString() + "\n", Should.<Element>operator_doubleArrow(_first, _element_2));245 246 }247}...
Source:HashBasedSpec2ResultMappingExampleGroupSpec.java
...44 this.m.parseSpec(_builder);45 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");46 SpecExecution _result = this.result(_exampleGroup);47 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result => typeof(Pending) but"48 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()49 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()50 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.operator_doubleArrow(_result, Pending.class));51 52 }53 54 @Test55 @Named("returns NotRun if children are not executed but have an implementation")56 @Order(2)57 public void _returnsNotRunIfChildrenAreNotExecutedButHaveAnImplementation() throws Exception {58 StringConcatenation _builder = new StringConcatenation();59 _builder.append("describe \"Root\"{");60 _builder.newLine();61 _builder.append("\t");62 _builder.append("fact \"fact 1\"{ \"with implementation\" }");63 _builder.newLine();64 _builder.append("\t");65 _builder.append("fact \"fact 2\"{ \"with implementation\" }");66 _builder.newLine();67 _builder.append("}");68 _builder.newLine();69 this.m.parseSpec(_builder);70 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");71 SpecExecution _result = this.result(_exampleGroup);72 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result => typeof(NotRun) but"73 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()74 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()75 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.operator_doubleArrow(_result, NotRun.class));76 77 }78 79 @Test80 @Named("passes if all children pass")81 @Order(3)82 public void _passesIfAllChildrenPass() throws Exception {83 StringConcatenation _builder = new StringConcatenation();84 _builder.append("describe \"Root\"{");85 _builder.newLine();86 _builder.append("\t");87 _builder.append("fact \"Example 1\"{ \"with implementation\" }");88 _builder.newLine();89 _builder.append("\t");90 _builder.append("fact \"Example 2\"{ \"with implementation\" }");91 _builder.newLine();92 _builder.append("}");93 _builder.newLine();94 this.m.parseSpec(_builder);95 this.passes("Example 1", "Example 2");96 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");97 SpecExecution _result = this.result(_exampleGroup);98 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result => typeof(Passed) but"99 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()100 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()101 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.operator_doubleArrow(_result, Passed.class));102 103 }104 105 @Test106 @Named("fails if one child has failed")107 @Order(4)108 public void _failsIfOneChildHasFailed() throws Exception {109 StringConcatenation _builder = new StringConcatenation();110 _builder.append("describe \"Root\"{");111 _builder.newLine();112 _builder.append("\t");113 _builder.append("fact \"Example 1\"{ \"with implementation\" }");114 _builder.newLine();115 _builder.append("\t");116 _builder.append("fact \"Example 2\"{ \"with implementation\" }");117 _builder.newLine();118 _builder.append("}");119 _builder.newLine();120 this.m.parseSpec(_builder);121 this.passes("Example 1");122 this.fails("Example 2");123 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");124 SpecExecution _result = this.result(_exampleGroup);125 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result => typeof(Failed) but"126 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()127 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()128 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.operator_doubleArrow(_result, Failed.class));129 130 }131 132 @Test133 @Named("execution time is sum of all child examples")134 @Order(5)135 public void _executionTimeIsSumOfAllChildExamples() throws Exception {136 StringConcatenation _builder = new StringConcatenation();137 _builder.append("describe \"Root\"{");138 _builder.newLine();139 _builder.append("\t");140 _builder.append("fact \"Example 1\"{ \"with implementation\" }");141 _builder.newLine();142 _builder.append("\t");143 _builder.append("fact \"Example 2\"{ \"with implementation\" }");144 _builder.newLine();145 _builder.append("}");146 _builder.newLine();147 this.m.parseSpec(_builder);148 this.exampleExecutedIn("Example 1", 1.0);149 this.exampleExecutedIn("Example 2", 2.0);150 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");151 SpecExecution _result = this.result(_exampleGroup);152 double _executionTimeInSeconds = _result.getExecutionTimeInSeconds();153 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result.executionTimeInSeconds => 3.0 but"154 + "\n m.exampleGroup(\"Root\").result.executionTimeInSeconds is " + new org.hamcrest.StringDescription().appendValue(Double.valueOf(_executionTimeInSeconds)).toString()155 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()156 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()157 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.<Double>operator_doubleArrow(Double.valueOf(_executionTimeInSeconds), Double.valueOf(3.0)));158 159 }160 161 @Test162 @Named("class name is from spec")163 @Order(6)164 public void _classNameIsFromSpec() throws Exception {165 StringConcatenation _builder = new StringConcatenation();166 _builder.append("describe \"Root\"{");167 _builder.newLine();168 _builder.append("\t");169 _builder.append("fact \"Example 1\"{ \"with implementation\" }");170 _builder.newLine();171 _builder.append("\t");172 _builder.append("fact \"Example 2\"{ \"with implementation\" }");173 _builder.newLine();174 _builder.append("}");175 _builder.newLine();176 this.m.parseSpec(_builder);177 this.passes("Example 1");178 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");179 SpecExecution _result = this.result(_exampleGroup);180 String _className = _result.getClassName();181 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result.className => \"RootSpec\" but"182 + "\n m.exampleGroup(\"Root\").result.className is " + new org.hamcrest.StringDescription().appendValue(_className).toString()183 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()184 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()185 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.<String>operator_doubleArrow(_className, "RootSpec"));186 187 }188 189 @Test190 @Named("name is from spec")191 @Order(7)192 public void _nameIsFromSpec() throws Exception {193 StringConcatenation _builder = new StringConcatenation();194 _builder.append("describe \"Root\"{");195 _builder.newLine();196 _builder.append("\t");197 _builder.append("fact \"Example 1\"");198 _builder.newLine();199 _builder.append("\t");200 _builder.append("fact \"Example 2\"");201 _builder.newLine();202 _builder.append("}");203 _builder.newLine();204 this.m.parseSpec(_builder);205 this.passes("Example 1");206 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");207 SpecExecution _result = this.result(_exampleGroup);208 String _name = _result.getName();209 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result.name => \"Root\" but"210 + "\n m.exampleGroup(\"Root\").result.name is " + new org.hamcrest.StringDescription().appendValue(_name).toString()211 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()212 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()213 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.<String>operator_doubleArrow(_name, "Root"));214 215 }216 217 @Test218 @Named("caches calculated results")219 @Order(8)220 public void _cachesCalculatedResults() throws Exception {221 StringConcatenation _builder = new StringConcatenation();222 _builder.append("describe \"Root\"{");223 _builder.newLine();224 _builder.append("\t");225 _builder.append("fact \"Example 1\"");226 _builder.newLine();227 _builder.append("\t");228 _builder.append("fact \"Example 2\"");229 _builder.newLine();230 _builder.append("}");231 _builder.newLine();232 this.m.parseSpec(_builder);233 this.passes("Example 1");234 final ExampleGroup exampleGroup = this.m.exampleGroup("Root");235 final SpecExecution first = this.result(exampleGroup);236 final SpecExecution second = this.result(exampleGroup);237 Matcher<SpecExecution> _sameInstance = CoreMatchers.<SpecExecution>sameInstance(second);238 Assert.assertTrue("\nExpected first => sameInstance(second) but"239 + "\n first is " + new org.hamcrest.StringDescription().appendValue(first).toString()240 + "\n sameInstance(second) is " + new org.hamcrest.StringDescription().appendValue(_sameInstance).toString()241 + "\n second is " + new org.hamcrest.StringDescription().appendValue(second).toString() + "\n", Should.<SpecExecution>operator_doubleArrow(first, _sameInstance));242 243 }244 245 @Test246 @Named("supports nested specs")247 @Order(9)248 public void _supportsNestedSpecs() throws Exception {249 StringConcatenation _builder = new StringConcatenation();250 _builder.append("describe \"Root\"{");251 _builder.newLine();252 _builder.append("\t");253 _builder.append("describe \"Child\"{");254 _builder.newLine();255 _builder.append("\t\t");256 _builder.append("fact \"Example 1\"{1 + 1 => 2}");257 _builder.newLine();258 _builder.append("\t");259 _builder.append("}\t");260 _builder.newLine();261 _builder.append("}");262 _builder.newLine();263 this.m.parseSpec(_builder);264 HashBasedSpec2ResultMappingExampleGroupSpec.CLASSNAME = "RootChildSpec";265 this.passes("Example 1");266 ExampleGroup _exampleGroup = this.m.exampleGroup("Root");267 SpecExecution _result = this.result(_exampleGroup);268 Assert.assertTrue("\nExpected m.exampleGroup(\"Root\").result => typeof(Passed) but"269 + "\n m.exampleGroup(\"Root\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()270 + "\n m.exampleGroup(\"Root\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()271 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.operator_doubleArrow(_result, Passed.class));272 273 }274 275 @Test276 @Ignore277 @Named("supports nested specs referencing methods [PENDING]")278 @Order(10)279 public void _supportsNestedSpecsReferencingMethods() throws Exception {280 StringConcatenation _builder = new StringConcatenation();281 _builder.append("describe String{");282 _builder.newLine();283 _builder.append("\t");284 _builder.append("describe charAt{");285 _builder.newLine();286 _builder.append("\t\t");287 _builder.append("fact \"Example 1\"{1 + 1 => 2}");288 _builder.newLine();289 _builder.append("\t");290 _builder.append("}\t");291 _builder.newLine();292 _builder.append("}");293 _builder.newLine();294 this.m.parseSpec(_builder);295 HashBasedSpec2ResultMappingExampleGroupSpec.CLASSNAME = "RootCharAtSpec";296 this.passes("Example 1");297 ExampleGroup _exampleGroup = this.m.exampleGroup("String");298 SpecExecution _result = this.result(_exampleGroup);299 Assert.assertTrue("\nExpected m.exampleGroup(\"String\").result => typeof(Passed) but"300 + "\n m.exampleGroup(\"String\").result is " + new org.hamcrest.StringDescription().appendValue(_result).toString()301 + "\n m.exampleGroup(\"String\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()302 + "\n m is " + new org.hamcrest.StringDescription().appendValue(this.m).toString() + "\n", Should.operator_doubleArrow(_result, Passed.class));303 304 }305 306 public void exampleExecutedIn(final String name, final double time) {307 Passed _passingSpec = Passed.passingSpec(HashBasedSpec2ResultMappingExampleGroupSpec.CLASSNAME, name, time);308 this.subject.accept(_passingSpec);309 }310 311 public void fails(final String name) {312 Failed _failingSpec = Failed.failingSpec(HashBasedSpec2ResultMappingExampleGroupSpec.CLASSNAME, name, HashBasedSpec2ResultMappingSpec.anyExecutionTime, this.anyFailure);313 this.subject.accept(_failingSpec);314 }315 316 public void passes(final String... names) {...
Source:ExtensionLibraryIterableIteratorHelpersSpec.java
...41 final List<Integer> values = JnarioCollectionLiterals.<Integer>list(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5));42 Integer _first = JnarioIterableExtensions.<Integer>first(values);43 boolean _doubleArrow = Should.<Integer>operator_doubleArrow(_first, Integer.valueOf(1));44 Assert.assertTrue("\nExpected values.first => 1 but"45 + "\n values.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()46 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow);47 48 Integer _last = IterableExtensions.<Integer>last(values);49 boolean _doubleArrow_1 = Should.<Integer>operator_doubleArrow(_last, Integer.valueOf(5));50 Assert.assertTrue("\nExpected values.last => 5 but"51 + "\n values.last is " + new org.hamcrest.StringDescription().appendValue(_last).toString()52 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_1);53 54 Integer _second = JnarioIterableExtensions.<Integer>second(values);55 boolean _doubleArrow_2 = Should.<Integer>operator_doubleArrow(_second, Integer.valueOf(2));56 Assert.assertTrue("\nExpected values.second => 2 but"57 + "\n values.second is " + new org.hamcrest.StringDescription().appendValue(_second).toString()58 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_2);59 60 Integer _third = JnarioIterableExtensions.<Integer>third(values);61 boolean _doubleArrow_3 = Should.<Integer>operator_doubleArrow(_third, Integer.valueOf(3));62 Assert.assertTrue("\nExpected values.third => 3 but"63 + "\n values.third is " + new org.hamcrest.StringDescription().appendValue(_third).toString()64 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_3);65 66 Integer _forth = JnarioIterableExtensions.<Integer>forth(values);67 boolean _doubleArrow_4 = Should.<Integer>operator_doubleArrow(_forth, Integer.valueOf(4));68 Assert.assertTrue("\nExpected values.forth => 4 but"69 + "\n values.forth is " + new org.hamcrest.StringDescription().appendValue(_forth).toString()70 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_4);71 72 Integer _fifth = JnarioIterableExtensions.<Integer>fifth(values);73 boolean _doubleArrow_5 = Should.<Integer>operator_doubleArrow(_fifth, Integer.valueOf(5));74 Assert.assertTrue("\nExpected values.fifth => 5 but"75 + "\n values.fifth is " + new org.hamcrest.StringDescription().appendValue(_fifth).toString()76 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_5);77 78 Integer _get = values.get(3);79 boolean _doubleArrow_6 = Should.<Integer>operator_doubleArrow(_get, Integer.valueOf(4));80 Assert.assertTrue("\nExpected values.get(3) => 4 but"81 + "\n values.get(3) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()82 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_6);83 84 final List<Object> objects = JnarioCollectionLiterals.<Object>list(Integer.valueOf(1), "string", Boolean.valueOf(true), "other string");85 String _first_1 = JnarioIterableExtensions.<String>first(objects, String.class);86 boolean _doubleArrow_7 = Should.<String>operator_doubleArrow(_first_1, "string");87 Assert.assertTrue("\nExpected objects.first(typeof(String)) => \"string\" but"88 + "\n objects.first(typeof(String)) is " + new org.hamcrest.StringDescription().appendValue(_first_1).toString()89 + "\n objects is " + new org.hamcrest.StringDescription().appendValue(objects).toString() + "\n", _doubleArrow_7);90 91 String _second_1 = JnarioIterableExtensions.<String>second(objects, String.class);92 Assert.assertTrue("\nExpected objects.second(typeof(String)) => \"other string\" but"93 + "\n objects.second(typeof(String)) is " + new org.hamcrest.StringDescription().appendValue(_second_1).toString()94 + "\n objects is " + new org.hamcrest.StringDescription().appendValue(objects).toString() + "\n", Should.<String>operator_doubleArrow(_second_1, "other string"));95 96 }97 98 /**99 * These methods work also for iterators. Note100 * that calling one of these methods will consume101 * the iterator to the position of the returned element.102 */103 @Test104 @Named("Iterators")105 @Order(2)106 public void _iterators() throws Exception {107 final List<Integer> values = JnarioCollectionLiterals.<Integer>list(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5));108 Iterator<Integer> _iterator = values.iterator();109 Integer _first = JnarioIteratorExtensions.<Integer>first(_iterator);110 boolean _doubleArrow = Should.<Integer>operator_doubleArrow(_first, Integer.valueOf(1));111 Assert.assertTrue("\nExpected values.iterator.first => 1 but"112 + "\n values.iterator.first is " + new org.hamcrest.StringDescription().appendValue(_first).toString()113 + "\n values.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator).toString()114 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow);115 116 Iterator<Integer> _iterator_1 = values.iterator();117 Integer _last = IteratorExtensions.<Integer>last(_iterator_1);118 boolean _doubleArrow_1 = Should.<Integer>operator_doubleArrow(_last, Integer.valueOf(5));119 Assert.assertTrue("\nExpected values.iterator.last => 5 but"120 + "\n values.iterator.last is " + new org.hamcrest.StringDescription().appendValue(_last).toString()121 + "\n values.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_1).toString()122 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_1);123 124 Iterator<Integer> _iterator_2 = values.iterator();125 Integer _get = JnarioIteratorExtensions.<Integer>get(_iterator_2, 3);126 boolean _doubleArrow_2 = Should.<Integer>operator_doubleArrow(_get, Integer.valueOf(4));127 Assert.assertTrue("\nExpected values.iterator.get(3) => 4 but"128 + "\n values.iterator.get(3) is " + new org.hamcrest.StringDescription().appendValue(_get).toString()129 + "\n values.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_2).toString()130 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_2);131 132 Iterator<Integer> _iterator_3 = values.iterator();133 Integer _second = JnarioIteratorExtensions.<Integer>second(_iterator_3);134 boolean _doubleArrow_3 = Should.<Integer>operator_doubleArrow(_second, Integer.valueOf(2));135 Assert.assertTrue("\nExpected values.iterator.second => 2 but"136 + "\n values.iterator.second is " + new org.hamcrest.StringDescription().appendValue(_second).toString()137 + "\n values.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_3).toString()138 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_3);139 140 Iterator<Integer> _iterator_4 = values.iterator();141 Integer _third = JnarioIteratorExtensions.<Integer>third(_iterator_4);142 boolean _doubleArrow_4 = Should.<Integer>operator_doubleArrow(_third, Integer.valueOf(3));143 Assert.assertTrue("\nExpected values.iterator.third => 3 but"144 + "\n values.iterator.third is " + new org.hamcrest.StringDescription().appendValue(_third).toString()145 + "\n values.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_4).toString()146 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_4);147 148 Iterator<Integer> _iterator_5 = values.iterator();149 Integer _forth = JnarioIteratorExtensions.<Integer>forth(_iterator_5);150 boolean _doubleArrow_5 = Should.<Integer>operator_doubleArrow(_forth, Integer.valueOf(4));151 Assert.assertTrue("\nExpected values.iterator.forth => 4 but"152 + "\n values.iterator.forth is " + new org.hamcrest.StringDescription().appendValue(_forth).toString()153 + "\n values.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_5).toString()154 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_5);155 156 Iterator<Integer> _iterator_6 = values.iterator();157 Integer _fifth = JnarioIteratorExtensions.<Integer>fifth(_iterator_6);158 boolean _doubleArrow_6 = Should.<Integer>operator_doubleArrow(_fifth, Integer.valueOf(5));159 Assert.assertTrue("\nExpected values.iterator.fifth => 5 but"160 + "\n values.iterator.fifth is " + new org.hamcrest.StringDescription().appendValue(_fifth).toString()161 + "\n values.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_6).toString()162 + "\n values is " + new org.hamcrest.StringDescription().appendValue(values).toString() + "\n", _doubleArrow_6);163 164 final List<Object> objects = JnarioCollectionLiterals.<Object>list(Integer.valueOf(1), "string", Boolean.valueOf(true), "other string");165 Iterator<Object> _iterator_7 = objects.iterator();166 String _first_1 = JnarioIteratorExtensions.<String>first(_iterator_7, String.class);167 boolean _doubleArrow_7 = Should.<String>operator_doubleArrow(_first_1, "string");168 Assert.assertTrue("\nExpected objects.iterator.first(typeof(String)) => \"string\" but"169 + "\n objects.iterator.first(typeof(String)) is " + new org.hamcrest.StringDescription().appendValue(_first_1).toString()170 + "\n objects.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_7).toString()171 + "\n objects is " + new org.hamcrest.StringDescription().appendValue(objects).toString() + "\n", _doubleArrow_7);172 173 Iterator<Object> _iterator_8 = objects.iterator();174 String _second_1 = JnarioIteratorExtensions.<String>second(_iterator_8, String.class);175 Assert.assertTrue("\nExpected objects.iterator.second(typeof(String)) => \"other string\" but"176 + "\n objects.iterator.second(typeof(String)) is " + new org.hamcrest.StringDescription().appendValue(_second_1).toString()177 + "\n objects.iterator is " + new org.hamcrest.StringDescription().appendValue(_iterator_8).toString()178 + "\n objects is " + new org.hamcrest.StringDescription().appendValue(objects).toString() + "\n", Should.<String>operator_doubleArrow(_second_1, "other string"));179 180 }181}...
Source:ExecutableIsPendingFeatureSpec.java
...29 Feature _feature = Features.feature("Without scenarios and without background");30 boolean _isPending = _feature.isPending();31 boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), true);32 Assert.assertTrue("\nExpected feature(\"Without scenarios and without background\").isPending() should be true but"33 + "\n feature(\"Without scenarios and without background\").isPending() is " + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()34 + "\n feature(\"Without scenarios and without background\") is " + new org.hamcrest.StringDescription().appendValue(_feature).toString() + "\n", _should_be);35 36 }37 38 @Test39 @Named("featureWith[implementedScenario].isPending[] should be false")40 @Order(2)41 public void _featureWithImplementedScenarioIsPendingShouldBeFalse() throws Exception {42 Scenario _implementedScenario = Features.implementedScenario();43 Feature _featureWith = Features.featureWith(_implementedScenario);44 boolean _isPending = _featureWith.isPending();45 boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), false);46 Assert.assertTrue("\nExpected featureWith(implementedScenario).isPending() should be false but"47 + "\n featureWith(implementedScenario).isPending() is " + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()48 + "\n featureWith(implementedScenario) is " + new org.hamcrest.StringDescription().appendValue(_featureWith).toString()49 + "\n implementedScenario is " + new org.hamcrest.StringDescription().appendValue(_implementedScenario).toString() + "\n", _should_be);50 51 }52 53 @Test54 @Named("featureWith[scenarioWithoutSteps, implementedScenario].isPending[] should be true")55 @Order(3)56 public void _featureWithScenarioWithoutStepsImplementedScenarioIsPendingShouldBeTrue() throws Exception {57 Scenario _scenarioWithoutSteps = Features.scenarioWithoutSteps();58 Scenario _implementedScenario = Features.implementedScenario();59 Feature _featureWith = Features.featureWith(_scenarioWithoutSteps, _implementedScenario);60 boolean _isPending = _featureWith.isPending();61 boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), true);62 Assert.assertTrue("\nExpected featureWith(scenarioWithoutSteps, implementedScenario).isPending() should be true but"63 + "\n featureWith(scenarioWithoutSteps, implementedScenario).isPending() is " + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()64 + "\n featureWith(scenarioWithoutSteps, implementedScenario) is " + new org.hamcrest.StringDescription().appendValue(_featureWith).toString()65 + "\n scenarioWithoutSteps is " + new org.hamcrest.StringDescription().appendValue(_scenarioWithoutSteps).toString()66 + "\n implementedScenario is " + new org.hamcrest.StringDescription().appendValue(_implementedScenario).toString() + "\n", _should_be);67 68 }69 70 @Test71 @Named("featureWithBackground[implementedBackground].isPending[] should be true")72 @Order(4)73 public void _featureWithBackgroundImplementedBackgroundIsPendingShouldBeTrue() throws Exception {74 Background _implementedBackground = Features.implementedBackground();75 Feature _featureWithBackground = Features.featureWithBackground(_implementedBackground);76 boolean _isPending = _featureWithBackground.isPending();77 boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), true);78 Assert.assertTrue("\nExpected featureWithBackground(implementedBackground).isPending() should be true but"79 + "\n featureWithBackground(implementedBackground).isPending() is " + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()80 + "\n featureWithBackground(implementedBackground) is " + new org.hamcrest.StringDescription().appendValue(_featureWithBackground).toString()81 + "\n implementedBackground is " + new org.hamcrest.StringDescription().appendValue(_implementedBackground).toString() + "\n", _should_be);82 83 }84 85 @Test86 @Named("featureWithBackground[backgroundWithoutSteps].isPending[] should be true")87 @Order(5)88 public void _featureWithBackgroundBackgroundWithoutStepsIsPendingShouldBeTrue() throws Exception {89 Background _backgroundWithoutSteps = Features.backgroundWithoutSteps();90 Feature _featureWithBackground = Features.featureWithBackground(_backgroundWithoutSteps);91 boolean _isPending = _featureWithBackground.isPending();92 boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), true);93 Assert.assertTrue("\nExpected featureWithBackground(backgroundWithoutSteps).isPending() should be true but"94 + "\n featureWithBackground(backgroundWithoutSteps).isPending() is " + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()95 + "\n featureWithBackground(backgroundWithoutSteps) is " + new org.hamcrest.StringDescription().appendValue(_featureWithBackground).toString()96 + "\n backgroundWithoutSteps is " + new org.hamcrest.StringDescription().appendValue(_backgroundWithoutSteps).toString() + "\n", _should_be);97 98 }99 100 @Test101 @Named("featureWithBackgroundAndScenario[backgroundWithoutSteps, implementedScenario].isPending[] should be true")102 @Order(6)103 public void _featureWithBackgroundAndScenarioBackgroundWithoutStepsImplementedScenarioIsPendingShouldBeTrue() throws Exception {104 Background _backgroundWithoutSteps = Features.backgroundWithoutSteps();105 Scenario _implementedScenario = Features.implementedScenario();106 Feature _featureWithBackgroundAndScenario = Features.featureWithBackgroundAndScenario(_backgroundWithoutSteps, _implementedScenario);107 boolean _isPending = _featureWithBackgroundAndScenario.isPending();108 boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), true);109 Assert.assertTrue("\nExpected featureWithBackgroundAndScenario(backgroundWithoutSteps, implementedScenario).isPending() should be true but"110 + "\n featureWithBackgroundAndScenario(backgroundWithoutSteps, implementedScenario).isPending() is " + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()111 + "\n featureWithBackgroundAndScenario(backgroundWithoutSteps, implementedScenario) is " + new org.hamcrest.StringDescription().appendValue(_featureWithBackgroundAndScenario).toString()112 + "\n backgroundWithoutSteps is " + new org.hamcrest.StringDescription().appendValue(_backgroundWithoutSteps).toString()113 + "\n implementedScenario is " + new org.hamcrest.StringDescription().appendValue(_implementedScenario).toString() + "\n", _should_be);114 115 }116 117 @Test118 @Named("featureWithBackgroundAndScenario[implementedBackground, implementedScenario].isPending[] should be false")119 @Order(7)120 public void _featureWithBackgroundAndScenarioImplementedBackgroundImplementedScenarioIsPendingShouldBeFalse() throws Exception {121 Background _implementedBackground = Features.implementedBackground();122 Scenario _implementedScenario = Features.implementedScenario();123 Feature _featureWithBackgroundAndScenario = Features.featureWithBackgroundAndScenario(_implementedBackground, _implementedScenario);124 boolean _isPending = _featureWithBackgroundAndScenario.isPending();125 boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), false);126 Assert.assertTrue("\nExpected featureWithBackgroundAndScenario(implementedBackground, implementedScenario).isPending() should be false but"127 + "\n featureWithBackgroundAndScenario(implementedBackground, implementedScenario).isPending() is " + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()128 + "\n featureWithBackgroundAndScenario(implementedBackground, implementedScenario) is " + new org.hamcrest.StringDescription().appendValue(_featureWithBackgroundAndScenario).toString()129 + "\n implementedBackground is " + new org.hamcrest.StringDescription().appendValue(_implementedBackground).toString()130 + "\n implementedScenario is " + new org.hamcrest.StringDescription().appendValue(_implementedScenario).toString() + "\n", _should_be);131 132 }133}...
Source:SuiteExecutableProviderSpec.java
...104 Suite _suite_1 = this.m.suite("Child 1");105 Suite _suite_2 = this.m.suite("Child 2");106 List<Suite> _list = JnarioCollectionLiterals.<Suite>list(_suite_1, _suite_2);107 Assert.assertTrue("\nExpected subject.getExecutables(suite(\"My Suite\")) => list(suite(\"Child 1\"), suite(\"Child 2\")) but"108 + "\n subject.getExecutables(suite(\"My Suite\")) is " + new org.hamcrest.StringDescription().appendValue(_executables).toString()109 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString()110 + "\n suite(\"My Suite\") is " + new org.hamcrest.StringDescription().appendValue(_suite).toString()111 + "\n list(suite(\"Child 1\"), suite(\"Child 2\")) is " + new org.hamcrest.StringDescription().appendValue(_list).toString()112 + "\n suite(\"Child 1\") is " + new org.hamcrest.StringDescription().appendValue(_suite_1).toString()113 + "\n suite(\"Child 2\") is " + new org.hamcrest.StringDescription().appendValue(_suite_2).toString() + "\n", Should.<List<? extends Executable>>operator_doubleArrow(_executables, _list));114 115 }116 117 @Test118 @Named("returns resolved specs via link")119 @Order(2)120 public void _returnsResolvedSpecsViaLink() throws Exception {121 StringConcatenation _builder = new StringConcatenation();122 _builder.append("package demo");123 _builder.newLine();124 _builder.append("import demo.*");125 _builder.newLine();126 _builder.append("#My Suite");127 _builder.newLine();128 _builder.newLine();129 _builder.append("- \"My Spec\"");130 _builder.newLine();131 _builder.append("- \"My Feature\"");132 _builder.newLine();133 this.m.parseSuite(_builder);134 Suite _suite = this.m.suite("My Suite");135 List<Executable> _executables = this.subject.getExecutables(_suite);136 Set<Executable> _set = IterableExtensions.<Executable>toSet(_executables);137 ExampleGroup _exampleGroup = this.m.exampleGroup("My Spec");138 Feature _feature = this.m.feature();139 Set<Specification> _set_1 = JnarioCollectionLiterals.<Specification>set(_exampleGroup, _feature);140 Assert.assertTrue("\nExpected subject.getExecutables(suite(\"My Suite\")).toSet => set(exampleGroup(\"My Spec\"), feature()) but"141 + "\n subject.getExecutables(suite(\"My Suite\")).toSet is " + new org.hamcrest.StringDescription().appendValue(_set).toString()142 + "\n subject.getExecutables(suite(\"My Suite\")) is " + new org.hamcrest.StringDescription().appendValue(_executables).toString()143 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString()144 + "\n suite(\"My Suite\") is " + new org.hamcrest.StringDescription().appendValue(_suite).toString()145 + "\n set(exampleGroup(\"My Spec\"), feature()) is " + new org.hamcrest.StringDescription().appendValue(_set_1).toString()146 + "\n exampleGroup(\"My Spec\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()147 + "\n feature() is " + new org.hamcrest.StringDescription().appendValue(_feature).toString() + "\n", Should.<Set<? extends Executable>>operator_doubleArrow(_set, _set_1));148 149 }150 151 @Test152 @Named("returns resolved specs via regex")153 @Order(3)154 public void _returnsResolvedSpecsViaRegex() throws Exception {155 StringConcatenation _builder = new StringConcatenation();156 _builder.append("package demo");157 _builder.newLine();158 _builder.append("import demo.*");159 _builder.newLine();160 _builder.append("#My Suite");161 _builder.newLine();162 _builder.newLine();163 _builder.append("- \\demo.*\\");164 _builder.newLine();165 _builder.newLine();166 this.m.parseSuite(_builder);167 Suite _suite = this.m.suite("My Suite");168 List<Executable> _executables = this.subject.getExecutables(_suite);169 Set<Executable> _set = IterableExtensions.<Executable>toSet(_executables);170 ExampleGroup _exampleGroup = this.m.exampleGroup("My Spec");171 ExampleGroup _exampleGroup_1 = this.m.exampleGroup("String");172 Feature _feature = this.m.feature();173 Set<Specification> _set_1 = JnarioCollectionLiterals.<Specification>set(_exampleGroup, _exampleGroup_1, _feature);174 Assert.assertTrue("\nExpected subject.getExecutables(suite(\"My Suite\")).toSet => set(exampleGroup(\"My Spec\"), exampleGroup(\"String\"), feature()) but"175 + "\n subject.getExecutables(suite(\"My Suite\")).toSet is " + new org.hamcrest.StringDescription().appendValue(_set).toString()176 + "\n subject.getExecutables(suite(\"My Suite\")) is " + new org.hamcrest.StringDescription().appendValue(_executables).toString()177 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString()178 + "\n suite(\"My Suite\") is " + new org.hamcrest.StringDescription().appendValue(_suite).toString()179 + "\n set(exampleGroup(\"My Spec\"), exampleGroup(\"String\"), feature()) is " + new org.hamcrest.StringDescription().appendValue(_set_1).toString()180 + "\n exampleGroup(\"My Spec\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup).toString()181 + "\n exampleGroup(\"String\") is " + new org.hamcrest.StringDescription().appendValue(_exampleGroup_1).toString()182 + "\n feature() is " + new org.hamcrest.StringDescription().appendValue(_feature).toString() + "\n", Should.<Set<? extends Executable>>operator_doubleArrow(_set, _set_1));183 184 }185}...
Source:CommandQueueSpec.java
...28 this.subject.add(task);29 int _size = this.subject.size();30 boolean _doubleArrow = Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(1));31 Assert.assertTrue("\nExpected subject.size => 1 but"32 + "\n subject.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()33 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString() + "\n", _doubleArrow);34 35 CommandQueue.Task<?> _take = this.subject.take();36 Assert.assertTrue("\nExpected subject.take => task but"37 + "\n subject.take is " + new org.hamcrest.StringDescription().appendValue(_take).toString()38 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString()39 + "\n task is " + new org.hamcrest.StringDescription().appendValue(task).toString() + "\n", Should.<CommandQueue.Task<?>>operator_doubleArrow(_take, task));40 41 }42 43 @Test44 @Named("take removes tasks")45 @Order(2)46 public void _takeRemovesTasks() throws Exception {47 Callback<Response> __ = Should.<Callback<Response>>_();48 final CommandQueue.Task<Response> task = CommandQueue.Task.<Response>create(Commands.ANY_COMMAND, __);49 this.subject.add(task);50 CommandQueue.Task<?> _take = this.subject.take();51 boolean _doubleArrow = Should.<CommandQueue.Task<?>>operator_doubleArrow(_take, task);52 Assert.assertTrue("\nExpected subject.take => task but"53 + "\n subject.take is " + new org.hamcrest.StringDescription().appendValue(_take).toString()54 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString()55 + "\n task is " + new org.hamcrest.StringDescription().appendValue(task).toString() + "\n", _doubleArrow);56 57 int _size = this.subject.size();58 boolean _doubleArrow_1 = Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(0));59 Assert.assertTrue("\nExpected subject.size => 0 but"60 + "\n subject.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()61 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString() + "\n", _doubleArrow_1);62 63 this.subject.add(task);64 int _size_1 = this.subject.size();65 Assert.assertTrue("\nExpected subject.size => 1 but"66 + "\n subject.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size_1)).toString()67 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(_size_1), Integer.valueOf(1)));68 69 }70 71 @Test72 @Named("duplicate commands and callbacks are discared")73 @Order(3)74 public void _duplicateCommandsAndCallbacksAreDiscared() throws Exception {75 Command<Response> _newCommand = Commands.newCommand("a");76 Callback<Response> __ = Should.<Callback<Response>>_();77 CommandQueue.Task<Response> _create = CommandQueue.Task.<Response>create(_newCommand, __);78 this.subject.add(_create);79 Command<Response> _newCommand_1 = Commands.newCommand("a");80 Callback<Response> ___1 = Should.<Callback<Response>>_();81 CommandQueue.Task<Response> _create_1 = CommandQueue.Task.<Response>create(_newCommand_1, ___1);82 this.subject.add(_create_1);83 int _size = this.subject.size();84 Assert.assertTrue("\nExpected subject.size => 1 but"85 + "\n subject.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()86 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(1)));87 88 }89 90 @Test91 @Named("clear all tasks")92 @Order(4)93 public void _clearAllTasks() throws Exception {94 Callback<Response> __ = Should.<Callback<Response>>_();95 CommandQueue.Task<Response> _create = CommandQueue.Task.<Response>create(Commands.ANY_COMMAND, __);96 this.subject.add(_create);97 this.subject.clear();98 int _size = this.subject.size();99 boolean _doubleArrow = Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(0));100 Assert.assertTrue("\nExpected subject.size => 0 but"101 + "\n subject.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()102 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString() + "\n", _doubleArrow);103 104 Callback<Response> ___1 = Should.<Callback<Response>>_();105 CommandQueue.Task<Response> _create_1 = CommandQueue.Task.<Response>create(Commands.ANY_COMMAND, ___1);106 this.subject.add(_create_1);107 int _size_1 = this.subject.size();108 Assert.assertTrue("\nExpected subject.size => 1 but"109 + "\n subject.size is " + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size_1)).toString()110 + "\n subject is " + new org.hamcrest.StringDescription().appendValue(this.subject).toString() + "\n", Should.<Integer>operator_doubleArrow(Integer.valueOf(_size_1), Integer.valueOf(1)));111 112 }113}...
toString
Using AI Code Generation
1import org.hamcrest.StringDescription2import org.hamcrest.MatcherAssert3import org.hamcrest.Matchers4def matcher = Matchers.is(5)5MatcherAssert.assertThat(5, matcher)6def description = new StringDescription()7description.appendDescriptionOf(matcher)8println description.toString()9import org.hamcrest.core.Is10def isMatcher = Is.is(5)11println isMatcher.toString()12import org.hamcrest.core.IsNot13def isNotMatcher = IsNot.not(5)14println isNotMatcher.toString()15import org.hamcrest.core.IsSame16def isSameMatcher = IsSame.sameInstance(5)17println isSameMatcher.toString()18import org.hamcrest.core.IsEqual19def isEqualMatcher = IsEqual.equalTo(5)20println isEqualMatcher.toString()21import org.hamcrest.core.AllOf22def allOfMatcher = AllOf.allOf(IsEqual.equalTo(5), IsEqual.equalTo(5))23println allOfMatcher.toString()24import org.hamcrest.core.AnyOf25def anyOfMatcher = AnyOf.anyOf(IsEqual.equalTo(5), IsEqual.equalTo(5))26println anyOfMatcher.toString()27import org.hamcrest.core.DescribedAs28def describedAsMatcher = DescribedAs.describedAs("description", IsEqual.equalTo(5))29println describedAsMatcher.toString()30import org.hamcrest.core.IsCollectionContaining31def isCollectionContainingMatcher = IsCollectionContaining.hasItem(5)32println isCollectionContainingMatcher.toString()33import org.hamcrest.core.IsCollectionContaining
toString
Using AI Code Generation
1assertThat("Hello World", equalTo("Hello World"))2assertThat("Hello World", equalTo("Hello World".toString()))3assertThat("Hello World", equalTo("Hello World".toString().toString()))4assertThat("Hello World", equalTo("Hello World".toString().toString().toString()))5assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString()))6assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString()))7assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString()))8assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString().toString()))9assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString().toString().toString()))10assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString().toString().toString().toString()))11assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString().toString().toString().toString().toString()))12assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString().toString().toString().toString().toString().toString()))13assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString().toString().toString().toString().toString().toString().toString()))14assertThat("Hello World", equalTo("Hello World".toString().toString().toString().toString().toString().toString().toString().toString().toString().toString().toString().toString().toString()))
toString
Using AI Code Generation
1def description = new StringDescription()2description.appendDescriptionOf(matcher)3println description.toString()4def description = new StringDescription()5MatcherAssert.assertThat(1, matcher)6println description.toString()7def description = new StringDescription()8MatcherAssert.assertThat(1, matcher)9println description.toString()10def description = new StringDescription()11MatcherAssert.assertThat(1, matcher)12println description.toString()13def description = new StringDescription()14MatcherAssert.assertThat(1, matcher)15println description.toString()16def description = new StringDescription()17MatcherAssert.assertThat(1, matcher)18println description.toString()19def description = new StringDescription()20MatcherAssert.assertThat(1, matcher)21println description.toString()22def description = new StringDescription()23MatcherAssert.assertThat(1, matcher)24println description.toString()25def description = new StringDescription()26MatcherAssert.assertThat(1, matcher)27println description.toString()28def description = new StringDescription()29MatcherAssert.assertThat(1, matcher)30println description.toString()31def description = new StringDescription()32MatcherAssert.assertThat(1, matcher)33println description.toString()34def description = new StringDescription()35MatcherAssert.assertThat(1, matcher)36println description.toString()
toString
Using AI Code Generation
1 def "test"() {2 def description = new StringDescription()3 description.appendText("hello")4 description.appendText("world")5 println description.toString()6 }7}8import org.hamcrest.StringDescription9import org.junit.Test10class TestRunner {11 void test() {12 def description = new StringDescription()13 description.appendText("hello")14 description.appendText("world")15 println description.asValue()16 }17}18import org.hamcrest.StringDescription19import org.junit.Test20class TestRunner {21 void test() {22 def description = new StringDescription()23 description.appendText("hello")24 description.appendText("world")25 println description.toString()26 }27}
toString
Using AI Code Generation
1def String toString(Object o) {2 def description = new StringDescription()3 description.appendValue(o)4 return description.toString()5}6def String toString(Object o, String label) {7 def description = new StringDescription()8 description.appendValue(label, o)9 return description.toString()10}11def String toString(Object o, String label, Object value) {12 def description = new StringDescription()13 description.appendValue(o)14 description.appendText(" ")15 description.appendValue(label)16 description.appendText(" ")17 description.appendValue(value)18 return description.toString()19}20def String toString(Object o, String label, Object value, String label2, Object value2) {21 def description = new StringDescription()22 description.appendValue(o)23 description.appendText(" ")24 description.appendValue(label)25 description.appendText(" ")26 description.appendValue(value)27 description.appendText(" ")28 description.appendValue(label2)29 description.appendText(" ")30 description.appendValue(value2)31 return description.toString()32}33def String toString(Object o, String label, Object value, String label2, Object value2, String label3, Object value3) {34 def description = new StringDescription()35 description.appendValue(o)36 description.appendText(" ")37 description.appendValue(label)38 description.appendText(" ")39 description.appendValue(value)40 description.appendText(" ")41 description.appendValue(label2)42 description.appendText(" ")43 description.appendValue(value2)44 description.appendText(" ")45 description.appendValue(label3)46 description.appendText(" ")47 description.appendValue(value3)48 return description.toString()49}50def String toString(Object o, String label, Object value, String label2, Object value2, String label3, Object value3, String label4, Object value4) {51 def description = new StringDescription()52 description.appendValue(o)53 description.appendText(" ")54 description.appendValue(label)55 description.appendText(" ")56 description.appendValue(value)57 description.appendText(" ")58 description.appendValue(label
toString
Using AI Code Generation
1import org.hamcrest.StringDescription2StringDescription description = new StringDescription()3description.appendDescriptionOf(greaterThan(10))4println description.toString()5import org.hamcrest.StringDescription6StringDescription description = new StringDescription()7description.appendDescriptionOf(greaterThan(10))8println description.toString()9import org.hamcrest.StringDescription10StringDescription description = new StringDescription()11description.appendDescriptionOf(greaterThan(10))12println description.toString()13import org.hamcrest.StringDescription14StringDescription description = new StringDescription()15description.appendDescriptionOf(greaterThan(10))16println description.toString()17import org.hamcrest.StringDescription18StringDescription description = new StringDescription()19description.appendDescriptionOf(greaterThan(10))20println description.toString()21import org.hamcrest.StringDescription22StringDescription description = new StringDescription()23description.appendDescriptionOf(greaterThan(10))24println description.toString()
LambdaTest also has a detailed JUnit tutorial explaining its features, importance, advanced use cases, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed JUnit testing chapters to help you get started:
You can also check out our JUnit certification if you wish to take your career in Selenium automation testing with JUnit to the next level.
Get 100 minutes of automation test minutes FREE!!