test92
auto test92 =
q{--- test92
// struct methods
struct Struct {
i32 member;
void set42() {
this.member += 42;
member = 42;
}
void set(i32 par) {
member = par;
this.member = par;
}
void set2() {
set42(); // pass this
}
void set3() {
set42; // pass this
}
void set4() {
this.set42; // explicit this
}
void set5() {
this.set42(); // explicit this
}
void set6() {
set(42); // pass this
}
}
i32 testMethod1() {
Struct s;
s.set42(); // take address
return s.member;
}
i32 testMethod2(i32 val) {
Struct s;
s.set(val); // take address
return s.member;
}
i32 testMethod3() {
Struct s;
s.set42; // take address
return s.member;
}
i32 testMethod4() {
Struct s;
Struct* sptr = &s;
sptr.set42; // call method on pointer
return sptr.member;
}
i32 testMethod5() {
Struct[1] s;
s[0].set42; // call method on index expr
s[0].set42();
s[0].set(42);
return s[0].member;
}
i32 testMethodToMethod2() {
Struct s = Struct(10); // reset stack value for future tests
s.set2;
return s.member;
}
i32 testMethodToMethod3() {
Struct s = Struct(10); // reset stack value for future tests
s.set3;
return s.member;
}
i32 testMethodToMethod4() {
Struct s = Struct(10); // reset stack value for future tests
s.set4;
return s.member;
}
i32 testMethodToMethod5() {
Struct s = Struct(10); // reset stack value for future tests
s.set5;
return s.member;
}
i32 testMethodToMethod6() {
Struct s = Struct(10); // reset stack value for future tests
s.set6;
return s.member;
}
};
tests passing
functionsvariables