-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
125d6b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
260-9f878bfa
discovered insrc/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.