import { validationRegexes } from "./validation-regexes.js";
/*
* TUTORIAL CONTENT LIVES HERE
* ---------------------------
* Edit this file to change examples, prompts, checks, or quick-check questions.
* The interface in app.js renders every lesson from this object automatically.
*
* Exercise checks are JavaScript regular expressions stored as strings. They are
* intentionally tolerant of spacing so learners can format Java naturally.
*/
export const tutorial = {
meta: {
title: "LiquidJava Interactive Tutorial",
eyebrow: "A hands-on interactive tutorial",
introduction:
"Learn how LiquidJava catches invalid values and illegal object behavior before a Java program runs.",
},
lessons: [
{
id: "values",
number: "02",
title: "Put boundaries on values",
shortTitle: "Values",
lead:
"A regular Java type says âthis is an integer.â A refinement can also limit that integer to the range expected by the program.",
concept: {
label: "Read the range",
code: '@Refinement("_ >= 0 && _ = and = 0 && _ = low && _ {
@StateRefinement(to="size(this) == 0")
public void ArrayList(); // Constructor
@StateRefinement(
to="size(this) == size(old(this)) + 1"
)
public boolean add(E element);
}`,
explanation:
"The ghost variable size records how many elements an ArrayList contains. add relates the new size to the old size.",
notes: [
"Ghost state exists for verification; it is not a runtime field.",
"old(this) refers to the object state before the method call.",
"Other refinements can use the ghost value to prevent out-of-bounds access.",
],
},
exercise: {
title: "Complete the stack refinements",
prompt:
"Replace the true refinements so the constructor, push, pop, and peek maintain and check the size ghost variable.",
starterCode: `import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.Ghost;
import liquidjava.specification.StateRefinement;
@ExternalRefinementsFor("java.util.Stack")
@Ghost("int size")
public interface StackRefinements