Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Nov 17, 2023
2 parents 3c3ce37 + e79966c commit 125d6b9
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ SOFTWARE.
<!-- version from the parent pom -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eolang</groupId>
<artifactId>jucs</artifactId>
<version>0.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
Expand All @@ -208,6 +214,7 @@ SOFTWARE.
<include>**/*.class</include>
<include>**/*.java</include>
<include>**/*.eo</include>
<include>**/*.yaml</include>
</includes>
</testResource>
</testResources>
Expand Down
59 changes: 59 additions & 0 deletions src/test/java/it/TrasformationPacksTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2023 Objectionary.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package it;

import org.eolang.jucs.ClasspathSource;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.params.ParameterizedTest;

/**
* Integration tests that verify that java code transforms into EO correctly.
* The test logic is as follows:
* 1. Compile java code into bytecode
* 2. Transform bytecode into XMIR
* 3. Compile expected EO into XMIR
* 4. Compare XMIRs
* @since 0.1
*/
final class TrasformationPacksTest {

@ParameterizedTest
@ClasspathSource(value = "packs", glob = "**.yaml")
void checksPack(final String pack) {
//@checkstyle MethodBodyCommentsCheck (10 lines)
// @todo #260:90min Implement primitive transformation test.
// Currently we just get the pack name from the test and check that it is not null.
// We have to implement proper transformation test. It will consist of the following steps:
// 1. Compile java code into bytecode
// 2. Transform bytecode into XMIR
// 3. Compile expected EO into XMIR
// 4. Compare XMIRs
MatcherAssert.assertThat(
"Pack is not null",
pack,
Matchers.notNullValue()
);
}
}
61 changes: 61 additions & 0 deletions src/test/resources/packs/simple_objects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
java:
Application.java: |
package com.example;
public class Application {
public static void main(String[] args) {
new B(new A(42)).bar();
}
}
A.java: |
package com.example;
public class A {
private final int x;
public A(int x) {
this.x = x;
}
public int foo() {
return x * 2;
}
}
B.java: |
package com.example;
public class B {
private final A a;
public B(A a) {
this.a = a;
}
public int bar() {
return a.foo() + 1;
}
}
eo:
Application.eo: |
package com.example
[] > Application
[args...] > main
seq > @
(b.new (a.new 42)).bar
A.eo: |
package com.example
[] > A
cage > x
[xa] > new
seq > @
x.write xa
[] > foo
seq > @
times
x
2
B.eo: |
package com.example
[] > B
cage > a
[aa] > new
seq > @
a.write aa
[] > bar
seq > @
plus
a.foo
1

1 comment on commit 125d6b9

@0pdd
Copy link

@0pdd 0pdd commented on 125d6b9 Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 260-9f878bfa discovered in src/test/java/it/TrasformationPacksTest.java) and submitted as #265. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.