Skip to content

Commit

Permalink
Add four more tests, fix invalid (yet unused) operator and for member…
Browse files Browse the repository at this point in the history
…s define the last comparator for
  • Loading branch information
Witixin1512 committed Feb 16, 2024
1 parent 299e85f commit 2ca88eb
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ private static MemberSet getString() {

private static void setup(MemberSet.Builder builder, BasicTypeID type) {
for (BuiltinMethodSymbol method : BuiltinMethodSymbol.values()) {
/*if (method.getID().equals(COMPARE)) {
if (method.getDefiningType().equals(type) && method.getID().equals(COMPARE)) {
comparator(builder, method, type);
} else if (method.getID().equals(CONSTRUCTOR)) {
}/* else if (method.getID().equals(CONSTRUCTOR)) {
builder.constructor(new MethodInstance(method));
} else if (method.getDefiningType() == type) {
builder.method(new MethodInstance(method));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public enum BuiltinMethodSymbol implements MethodSymbol {
USIZE_SHL(USIZE, SHL, USIZE, USIZE),
USIZE_SHR(USIZE, SHR, USIZE, USIZE),
USIZE_COMPARE(USIZE, COMPARE, INT, USIZE),
USIZE_COMPARE_UINT(USIZE, COMPARE, INT, USIZE),
USIZE_COMPARE_UINT(USIZE, COMPARE, INT, UINT),
USIZE_TO_BYTE(USIZE, MethodID.caster(BYTE), Modifiers.NONE, BYTE),
USIZE_TO_SBYTE(USIZE, MethodID.caster(SBYTE), Modifiers.NONE, SBYTE),
USIZE_TO_SHORT(USIZE, MethodID.caster(SHORT), Modifiers.NONE, SHORT),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#output: 3
#output: 3

public class Collision {
public static min(a as int, b as int) as int {
return a < b ? a : b;
}
public static min(a as double, b as double) as double {
return a < b ? a : b;
}
public static min(a as usize, b as usize) as usize {
return a < b ? a : b;
}
}

println("" + Collision.min(3, 5));
println("" + Collision.min(5, 3));
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#output: Hello Collision!
#output: Hello World!

public class Collision {
public this() {}

public print_collision() as void {
println("Hello World!");
}
public static print_collision() as void {
println("Hello Collision!");
}
}

Collision.print_collision();
new Collision().print_collision();
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#output: 4

public class Collision {
private val min as int;

public this(a as int) {
this.min = a;
}

public min(min as int) as int {
return min < this.min ? min : this.min;
}
}

val min = new Collision(5);
println("" + min.min(4));

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#output: int
#output: 4

public class min {
private val min as int;

public this(a as int) {
this.min = a;
}

public min(min as int) as int {
println(typeof(this.min));
return min < this.min ? min : this.min;
}
}

val min = new min(5);
println("" + min.min(4));

0 comments on commit 2ca88eb

Please sign in to comment.