t27.aiРусский

Five myths, each put to a test

You will learn

A sentence that sounds right can be settled by a small case and a test, so you can check a myth instead of arguing about it.

Five sentences about vibecoding sound right and are not. If it runs without an error, it is right: the average of 4 and 8 written as a plus b over 2 prints 8, and the answer is 6. One passing test proves the code is right: x times x equals x plus x at 2, and not at 3. The agent remembers the whole conversation: it reads a window, 8 messages of the 20 sent in this case. A step can always be undone: 7 halved and doubled is 6. A check that passes is a good check: one that says yes to everything also says yes to 2 against 3. Each myth is a small case, and a test settles it.

Try it

Run the spec: 6 tests pass. Change AVG_RAN from 8 to 6 and run it: myth_1_runs_but_wrong fails, because the run no longer matches what the wrong program prints. Then write a sixth myth of your own as a case with numbers and a test.

Open the interactive lesson →

Vibecoding 3: five myths, each put to a test ↗

Five sentences that sound right about vibecoding, each settled by a small case a test can run. Lesson 3 of the vibecoding course.

specs/vibecoding/myth_tests.t27

// SPDX-License-Identifier: Apache-2.0
; Vibecoding lesson 3: five myths, each put to a test.
; A myth is a sentence that sounds right. Each one below has a small case a test can settle.

module vc_myth_tests;

pub const MYTHS : [5]str = [
    "If it runs without an error, it is right.",
    "One passing test proves the code is right.",
    "The agent remembers the whole conversation.",
    "A step you do can always be undone.",
    "A check that passes is a good check."
];

; Myth 1. average(a, b) written as a + b / 2 runs, and gives the wrong answer.
pub fn average_wrong(a: u16, b: u16) -> u16 {
    return a + b / 2;
}

pub const AVG_A : u16 = 4;
pub const AVG_B : u16 = 8;
pub const AVG_RAN : u16 = 8;

; Myth 2. double(x) written as x * x agrees with x + x at 2 and at nothing else but 0.
pub fn double_wrong(x: u16) -> u16 {
    return x * x;
}

pub const PROBE_ONE : u16 = 2;
pub const PROBE_TWO : u16 = 3;

; Myth 3. An agent reads a window of recent messages, not all of them.
pub const MESSAGES_SENT : u16 = 20;
pub const WINDOW : u16 = 8;
pub const MESSAGES_KEPT : u16 = 8;

; Myth 4. Halving and then doubling a whole number does not always give it back.
pub const ODD : u16 = 7;
pub const EVEN : u16 = 8;

; Myth 5. A check that says yes to everything also passes the wrong run.
pub const CHECK_SAYS_YES_TO_ALL : bool = true;
pub const GOT : u16 = 2;
pub const WANT : u16 = 3;

test myth_1_runs_but_wrong {
    assert AVG_RAN == AVG_A + AVG_B / 2;
    assert AVG_RAN != (AVG_A + AVG_B) / 2;
}

test myth_2_one_test_is_not_enough {
    assert PROBE_ONE * PROBE_ONE == PROBE_ONE + PROBE_ONE;
    assert PROBE_TWO * PROBE_TWO != PROBE_TWO + PROBE_TWO;
}

test myth_3_the_window_is_smaller_than_the_talk {
    assert MESSAGES_KEPT == WINDOW;
    assert MESSAGES_KEPT < MESSAGES_SENT;
}

test myth_4_undo_is_not_free {
    assert EVEN / 2 * 2 == EVEN;
    assert ODD / 2 * 2 != ODD;
}

test myth_5_a_check_that_cannot_fail {
    assert CHECK_SAYS_YES_TO_ALL == true;
    assert GOT != WANT;
}

test five_myths_listed {
    assert MYTHS[0] == "If it runs without an error, it is right.";
    assert MYTHS[4] == "A check that passes is a good check.";
}

Open the lesson's spec in the player ↗

All lessons