Skip to content

Commit

Permalink
feat(objectionary#86): add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Jan 16, 2024
1 parent f879114 commit 78b2e71
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/test/java/org/eolang/opeo/ast/InvocationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
package org.eolang.opeo.ast;

import com.jcabi.matchers.XhtmlMatchers;
import org.eolang.opeo.compilation.HasInstructions;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.Test;
import org.objectweb.asm.Opcodes;
import org.xembly.ImpossibleModificationException;
import org.xembly.Transformers;
import org.xembly.Xembler;
Expand Down Expand Up @@ -65,4 +67,24 @@ void transformsToXmir() throws ImpossibleModificationException {
)
);
}

@Test
void transformsToOpcodes() {
final String name = "bar";
final String constant = "baz";
MatcherAssert.assertThat(
"Can't transform 'invocation' to correct opcodes",
new OpcodeNodes(new Invocation(new This(), name, new Literal(constant))).opcodes(),
new HasInstructions(
new HasInstructions.Instruction(Opcodes.ALOAD, 0),
new HasInstructions.Instruction(Opcodes.LDC, constant),
new HasInstructions.Instruction(
Opcodes.INVOKEVIRTUAL,
"???owner???",
name,
"(Ljava/lang/String;)Ljava/lang/String;"
)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ private boolean verifyOperands(final XmlNode node, final int index) {
if (!operand.equals(expected)) {
this.warnings.add(
String.format(
"Bytecode instruction at %d index should have opcode with operands %s but got %s instead",
"Bytecode instruction at %d index should have opcode with operands %s but got %s instead, ('%s' != '%s')",
index,
operand,
expected
expected,
new HexString(operand.text()).decode(),
new HexString(expected.text()).decode()
)
);
result = false;
Expand Down

0 comments on commit 78b2e71

Please sign in to comment.