Skip to content

Instantly share code, notes, and snippets.

Behaviour:
update the inventory of my store
Input: inventory = [products] = [{sellin: x, Q: y, desc: "Theatre Passes"}, ...]
Output: inventory' = [{sellin: x', Q: y', desc: "Theatre Passes"}, ...]
Smaller behaviours:
1. Update sellin:

Calculating final price per unit of a product.

As a seller I'd like to compute the final price of a product including taxes in order to show it to my customers.

  1. Products have a cost per unit and tax percentage to apply.
  2. The cost per unit is in euros.
  3. The final price has to be rounded up. For instance, if the calculated final price of a product is 1.7825€, the expected final price for that product is 1.79€.
  4. The final price of the product is then calculated as the cost per unit with the taxes rounded up.
@trikitrok
trikitrok / CourseState.java
Last active March 22, 2026 00:03
Final state machine using copilot
package course_duration.domain;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
public abstract class CourseState {
private static final Duration MAX_MINUTES_SHORT_COURSES = Duration.ofMinutes(10);
@trikitrok
trikitrok / Element.java
Created February 8, 2026 22:36
Used to illustrate finding test points
public class Element {
private final String name;
private String text;
public Element(String name) {
this.name = name;
this.text = "";
}
public void addText(String newText) {
public class Invoice {
private final ShippingPricer shippingPricer;
// ...
public Invoice(
OurDate billingDate,
OurDate openingDate,
Originator originator
// ...
) {
public class Invoice {
//...
public Money getValue() {
Money total = this.itemsSum();
if (this.billingDate.after(OurDate.yearEnd(this.openingDate))) {
if (
this.originator.getState().equals("FL") ||
this.originator.getState().equals("NY")
) {
@trikitrok
trikitrok / InMemoryDirectory.java
Created February 8, 2026 22:29
Used to illustrate finding test points
public class InMemoryDirectory {
private final List<Element> elements;
public InMemoryDirectory() {
this.elements = new ArrayList<>();
}
public void addElement(Element newElement) {
this.elements.add(newElement);
}
@trikitrok
trikitrok / AlarmTest.java
Last active February 9, 2026 08:31
Alarm tests with no relevant mutants surviving
package unit_tests;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import tirepressuremonitoringsystem.Alarm;
import java.util.*;
import java.util.stream.Stream;
@trikitrok
trikitrok / ArgentRoseStore.java
Created February 1, 2026 22:25
Code after finding and fixing bugs
package com.argentrose;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public class ArgentRoseStore {
private final List<Product> inventory;
@trikitrok
trikitrok / ArgentRoseStore.java
Last active February 1, 2026 21:43
Production code with manual mutation that pit can't create
package com.argentrose;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public class ArgentRoseStore {
private final List<Product> inventory;