Skip to content

Commit

Permalink
objectionary#2863 add extra object to reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Mar 4, 2024
1 parent 67d14ee commit 72632f2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/simian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- run: |
wget --quiet http://public.yegor256.com/simian.jar -O /tmp/simian.jar
- run: |
java -jar /tmp/simian.jar -threshold=25 -excludes=**/gen -excludes=**/it **/*.java
java -jar /tmp/simian.jar -threshold=15 -excludes=**/gen -excludes=**/it **/*.java
67 changes: 39 additions & 28 deletions eo-runtime/src/test/java/org/eolang/PhConstTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,7 @@ void keepsConstMultiLayers() {
@Test
void dataizesOnlyOnceViaEnvelopes() {
final Dummy dummy = new Dummy("x");
final Phi phi = new PhConst(
new PhWith(
new Envelope(Phi.Φ),
0,
new PhWith(
new Envelope(Phi.Φ),
0,
new PhWith(
new Envelope(Phi.Φ),
0, dummy
)
)
)
);
final Phi phi = new PhConst(new EnvelopedDummy(Phi.Φ, dummy));
phi.attr("eq").get();
new Dataized(phi).take(Long.class);
MatcherAssert.assertThat(
Expand All @@ -196,20 +183,7 @@ void dataizesOnlyOnceViaEnvelopes() {
@Test
void dataizesOnlyOnceViaMethods() {
final Dummy dummy = new Dummy("x");
final Phi phi = new PhConst(
new PhWith(
new Envelope(Phi.Φ),
0,
new PhWith(
new Envelope(Phi.Φ),
0,
new PhWith(
new Envelope(Phi.Φ),
0, dummy
)
)
)
);
final Phi phi = new PhConst(new EnvelopedDummy(Phi.Φ, dummy));
new Dataized(phi).take();
new Dataized(phi).take();
MatcherAssert.assertThat(
Expand Down Expand Up @@ -309,6 +283,43 @@ private static class Envelope extends PhDefault {
}
}

/**
* Enveloped dummy Phi.
* @since 1.0
*/
private static class EnvelopedDummy extends PhDefault {
/**
* Ctor.
* @param sigma Sigma
* @param dummy Dummy to be enveloped
*/
EnvelopedDummy(final Phi sigma, final Phi dummy) {
super(sigma);
this.add(
"φ",
new AtComposite(
this,
self -> new Data.ToPhi(
new Dataized(
new PhWith(
new Envelope(Phi.Φ),
0,
new PhWith(
new Envelope(Phi.Φ),
0,
new PhWith(
new Envelope(Phi.Φ),
0, dummy
)
)
)
).take(Long.class)
)
)
);
}
}

/**
* Boom Phi.
* @since 1.0
Expand Down

0 comments on commit 72632f2

Please sign in to comment.