Updated tests and fixed grammar

This commit is contained in:
2026-06-23 03:44:54 +02:00
parent 2ae4ca510d
commit 2f6303ba30
14 changed files with 135 additions and 134 deletions
+9 -9
View File
@@ -1,23 +1,23 @@
pub module struct_test;
struct Point {
x i32,
y i32,
i32 x,
i32 y,
}
pub fn void test_struct_create_access() {
pub void test_struct_create_access() {
let p = Point { x: 10, y: 20 };
assert_eq!(p.x, 10);
assert_eq!(p.y, 20);
}
pub fn void test_struct_mut_field() {
pub void test_struct_mut_field() {
let mut p = Point { x: 1, y: 2 };
p.x = 100;
assert_eq!(p.x, 100);
}
pub fn void test_struct_destructure() {
pub void test_struct_destructure() {
let p = Point { x: 3, y: 4 };
let Point { x, y } = p;
assert_eq!(x, 3);
@@ -25,11 +25,11 @@ pub fn void test_struct_destructure() {
}
struct Line {
start Point,
end Point,
Point start,
Point end,
}
pub fn void test_struct_nested() {
pub void test_struct_nested() {
let l = Line {
start: Point { x: 0, y: 0 },
end: Point { x: 5, y: 10 },
@@ -38,7 +38,7 @@ pub fn void test_struct_nested() {
assert_eq!(l.end.y, 10);
}
pub fn void run_tests() {
pub void run_tests() {
test_struct_create_access();
test_struct_mut_field();
test_struct_destructure();