From 76fff878db8aeaf6f0f72411757025aa71001eb2 Mon Sep 17 00:00:00 2001 From: Sam Lenz Date: Thu, 1 Aug 2024 16:58:40 -0400 Subject: [PATCH] added NA-323 and comparison of Specimin->Perses output --- differences-between-specimin-and-perses.md | 126 ++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/differences-between-specimin-and-perses.md b/differences-between-specimin-and-perses.md index 89ff481..dfac419 100644 --- a/differences-between-specimin-and-perses.md +++ b/differences-between-specimin-and-perses.md @@ -59,4 +59,128 @@ Differences: * Specimin removes the `VERSION_INFORMATION` field, which apparently doesn't contribute to the error (why does Perses keep it?) * Specimin replaces the body of `getAllVersionInformation()` with `throw new Error();`, but Perses leaves it as-is * Perses moves the contents of the target method `method()` to an initializer block -* Perses removes the `final` from the declaration of the `versionInfo` local \ No newline at end of file +* Perses removes the `final` from the declaration of the `versionInfo` local + +## NA-323 + +Specimin Output: +``` +package com.cogvio.time; + +import java.time.Clock; +import java.time.Instant; +import java.time.ZoneId; + +public final class MutableClock extends Clock { + + private Instant instant; + + private ZoneId zone; + + private MutableClock(final Instant instant, final ZoneId zone) { + this.setZone(zone); + this.setInstant(instant); + } + + public void setInstant(final Instant instant) { + throw new Error(); + } + + public void setZone(final ZoneId zone) { + throw new Error(); + } + + public ZoneId getZone() { + throw new Error(); + } + + public MutableClock withZone(final ZoneId newZone) { + throw new Error(); + } + + public Instant instant() { + throw new Error(); + } +} + +``` + +Perses Output: +``` +package com.cogvio.time; + +import java.time.Instant; +import java.time.ZoneId; + +class MutableClock { + Instant instant; + ZoneId zone; + + MutableClock() {} +} + +``` +Line counts using same formatting: +* Specimin: 27 +* Perses: 8 + +Differences: +* Perses doesn't include clock +* Perses removes "public final" before "class" in class declaration and removes "extends" +* Perses removes "private" from variable declarations +* Perses removes arguments for MutableClock() +* Specimin replaces the body of the setters and getters with "throw new Error();" while perses removes them entirely + +## Running Perses on Specimin Output + +We also ran Perses on the output of Specimin for two cases where the output was +preserved by Specimin, and the output was a single file. + +## CF-4614 + +Perses Output: +``` +import java.util.Map; +import java.util.stream.Collectors; + +class Version { + static Map getAllVersionInformation() { + throw new Error(); + } + + { + String versionInfo = + Version.getAllVersionInformation().entrySet().stream() + .map(e -> String.format("%s:%s", e.getKey(), e.getValue())) + .collect(Collectors.joining()); + } +} + +``` +lines: 13 + +Differences: +* One less line than Perses due to Specimin removing the `VERSION_INFORMATION` field +* `getAllVersionInformation` is kept in both, but Specimin changed the body to "throw new Error()" which Perses kept + +## NA-323 + +Perses Output: +``` +package com.cogvio.time; + +import java.time.Instant; +import java.time.ZoneId; + +class MutableClock { + Instant instant; + ZoneId zone; + + MutableClock() {} +} + +``` +lines: 8 + +Differences: +* None, Perses produced the same output after help from Specimin