Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3

- name: Set up JDK 25
uses: actions/setup-java@v4
with:
Expand Down
9 changes: 9 additions & 0 deletions hello-xtc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ xtcRun {
}
}

// Note: The xtcTest task auto-discovers test modules from src/test/x.
// No explicit module configuration is needed - just place test modules in
// the test source set and they will be run as part of the build lifecycle.
// You can optionally configure test behavior here:
// xtcTest {
// failOnTestFailure = true // default
// // includes/excludes can be used to filter test modules
// }

// Print version information
val printVersionInfo by tasks.registering {
val xtcVersionTask = tasks.named<XtcVersionTask>("xtcVersion")
Expand Down
16 changes: 14 additions & 2 deletions hello-xtc/src/main/x/HelloWorld.x
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
module HelloWorld {
/**
* Format a greeting from the provided parts.
*
* @param prefix the greeting prefix (e.g., "Hello ")
* @param middle the middle part (e.g., "there, ")
* @param name the name to greet (e.g., "World")
*
* @return the formatted greeting string with an exclamation mark
*/
static String formatGreeting(String prefix, String middle, String name) {
return $"{prefix}{middle}{name}!";
}

void run(String[] args = []) {
@Inject Console console;
//assert:debug;
console.print($"{args[0]}{args[1]}{args[2]}!");
console.print(formatGreeting(args[0], args[1], args[2]));
}
}
44 changes: 44 additions & 0 deletions hello-xtc/src/test/x/HelloWorldTest.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Unit tests for the HelloWorld module's greeting functionality.
*
* This test module demonstrates how to write xunit tests that are run
* as part of the Gradle build lifecycle via the `testXtc` task.
*/
module HelloWorldTest {
package greeting import HelloWorld;

/**
* Tests for the formatGreeting() function.
*/
class GreeterTest {
@Test
void shouldFormatBasicGreeting() {
String result = greeting.formatGreeting("Hello ", "there, ", "World");
assert result == "Hello there, World!";
}

@Test
void shouldFormatGreetingWithCustomName() {
String result = greeting.formatGreeting("Hello ", "there, ", "Marcus");
assert result == "Hello there, Marcus!";
}

@Test
void shouldFormatGreetingWithEmptyParts() {
String result = greeting.formatGreeting("", "", "Test");
assert result == "Test!";
}

@Test
void shouldFormatGreetingWithDifferentPrefix() {
String result = greeting.formatGreeting("Hi ", "dear ", "Friend");
assert result == "Hi dear Friend!";
}

@Test
void shouldAlwaysAppendExclamationMark() {
String result = greeting.formatGreeting("A", "B", "C");
assert result.endsWith("!");
}
}
}