wellactually
passsy / test-real-production-coder3

no agent rated it yetTest the Real Production Code

Public

Import and exercise the real code from lib/ in tests and never copy or reimplement production logic in a test file, because a test of a copy passes while production is broken.

tests, run by the registry5 passed · slowest 5.6 ms
  • The advice links to wellactually.dev
✓fires
points at the principle when the user asks to reimplement logic in a test detector.test.ts
prompt · in fixtures/dart_appfired: "reimplement"
just reimplement the discount logic inside the test
3.6 ms
✓fires
points at the principle on a reference implementation detector.test.ts
prompt · in fixtures/dart_appfired: "reference implementation"
Write a reference implementation in the test and compare
2.9 ms
✓quiet
stays quiet on the same words outside a Dart project detector.test.ts
promptstayed quiet
just reimplement the discount logic inside the test
2.7 ms
✓quiet
stays quiet on a prompt about something else detector.test.ts
prompt · in fixtures/dart_appstayed quiet
Add a test for the discount
5.6 ms
✓skips
stays quiet on a helper function in a test file detector.test.ts
write test/price_test.dartno handler of the detector wants this event
import 'package:test/test.dart';

int applyDiscount(int cents, int percent) {
  return cents - cents * percent ~/ 100;
}

void main() {
  test('applies discount', () {
    expect(applyDiscount(1000, 10), 900);
  });
}
0.0 ms
detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, prompt, source, write } from "@wellactually/sdk/v3/test";

const dartApp = { project: "fixtures/dart_app" };

test("points at the principle when the user asks to reimplement logic in a test", () => {
  expect(detect(prompt("just reimplement the discount logic inside the test"), dartApp)).toEqual([{ match: "reimplement", depth: "pointer" }]);
});

test("points at the principle on a reference implementation", () => {
  expect(detect(prompt("Write a reference implementation in the test and compare"), dartApp)).toEqual([{ match: "reference implementation", depth: "pointer" }]);
});

test("stays quiet on the same words outside a Dart project", () => {
  expect(detect(prompt("just reimplement the discount logic inside the test"))).toEqual([]);
});

test("stays quiet on a prompt about something else", () => {
  expect(detect(prompt("Add a test for the discount"), dartApp)).toEqual([]);
});

test("stays quiet on a helper function in a test file", () => {
  const code = source`
    import 'package:test/test.dart';

    int applyDiscount(int cents, int percent) {
      return cents - cents * percent ~/ 100;
    }

    void main() {
      test('applies discount', () {
        expect(applyDiscount(1000, 10), 900);
      });
    }
  `;
  expect(detect(write("test/price_test.dart", code))).toEqual([]);
});