Expanded comparison test and fixed some typos/mistakes

This commit is contained in:
Mattia Giambirtone 2022-08-15 20:09:54 +02:00
parent 70a5f9dcd3
commit 5dc8ce437c
3 changed files with 110 additions and 8 deletions

View File

@ -621,13 +621,13 @@ proc dispatch*(self: PeonVM) =
of NotEqualInt64:
self.push(PeonObject(kind: Bool, boolean: self.pop().long != self.pop().long))
of LessThanUInt64:
self.push(PeonObject(kind: Bool, boolean: self.pop().long < self.pop().long))
self.push(PeonObject(kind: Bool, boolean: self.pop().uLong < self.pop().uLong))
of GreaterThanUInt64:
self.push(PeonObject(kind: Bool, boolean: self.pop().long !> self.pop().long))
self.push(PeonObject(kind: Bool, boolean: self.pop().uLong !> self.pop().uLong))
of EqualUInt64:
self.push(PeonObject(kind: Bool, boolean: self.pop().long == self.pop().long))
self.push(PeonObject(kind: Bool, boolean: self.pop().uLong == self.pop().uLong))
of NotEqualUInt64:
self.push(PeonObject(kind: Bool, boolean: self.pop().long != self.pop().long))
self.push(PeonObject(kind: Bool, boolean: self.pop().uLong != self.pop().uLong))
of LessThanInt32:
self.push(PeonObject(kind: Bool, boolean: self.pop().`int` < self.pop().`int`))
of GreaterThanInt32:
@ -643,7 +643,7 @@ proc dispatch*(self: PeonVM) =
of EqualUInt32:
self.push(PeonObject(kind: Bool, boolean: self.pop().uInt == self.pop().uInt))
of NotEqualUInt32:
self.push(PeonObject(kind: Bool, boolean: self.pop().long != self.pop().long))
self.push(PeonObject(kind: Bool, boolean: self.pop().uInt != self.pop().uInt))
of LessThanInt16:
self.push(PeonObject(kind: Bool, boolean: self.pop().short < self.pop().short))
of GreaterThanInt16:

View File

@ -1080,7 +1080,7 @@ proc handleBuiltinFunction(self: Compiler, fn: Name, args: seq[Expression]) =
of "NotEqualInt8":
self.emitByte(NotEqualInt8)
of "LessThanUInt8":
self.emitByte(LessThanInt64)
self.emitByte(LessThanUInt8)
of "GreaterThanUInt8":
self.emitByte(GreaterThanUInt8)
of "EqualUInt8":

View File

@ -1,8 +1,110 @@
import std;
# int64
print(3 > 2); # true
print(2 < 3); # true
print(3 < 2); # false
print(2 == 3); # false
print(2 > 3); # false
print(2 != 3); # true
print(3 != 2); # true
print(3 == 2); # false
print(2 == 3); # false
# uint64
var x = 3'u64;
var y = 2'u64;
print(x > y); # true
print(y < x); # true
print(x < y); # false
print(y > x); # false
print(y != x); # true
print(x != y); # true
print(x == y); # false
print(y == x); # false
# int32
var x1 = 3'i32;
var y1 = 2'i32;
print(x1 > y1); # true
print(y1 < x1); # true
print(x1 < y1); # false
print(y1 > x1); # false
print(y1 != x1); # true
print(x1 != y1); # true
print(x1 == y1); # false
print(y1 == x1); # false
# uint32
var x2 = 3'u32;
var y2 = 2'u32;
print(x2 > y2); # true
print(y2 < x2); # true
print(x2 < y2); # false
print(y2 > x2); # false
print(y2 != x2); # true
print(x2 != y2); # true
print(x2 == y2); # false
print(y2 == x2); # false
# int16
var x3 = 3'i16;
var y3 = 2'i16;
print(x3 > y3); # true
print(y3 < x3); # true
print(x3 < y3); # false
print(y3 > x3); # false
print(y3 != x3); # true
print(x3 != y3); # true
print(x3 == y3); # false
print(y3 == x3); # false
# uint16
var x4 = 3'u16;
var y4 = 2'u16;
print(x4 > y4); # true
print(y4 < x4); # true
print(x4 < y4); # false
print(y4 > x4); # false
print(y4 != x4); # true
print(x4 != y4); # true
print(x4 == y4); # false
print(y4 == x4); # false
# int8
var x5 = 3'i8;
var y5 = 2'i8;
print(x5 > y5); # true
print(y5 < x5); # true
print(x5 < y5); # false
print(y5 > x5); # false
print(y5 != x5); # true
print(x5 != y5); # true
print(x5 == y5); # false
print(y5 == x5); # false
# uint8
var x6 = 3'u8;
var y6 = 2'u8;
print(x6 > y6); # true
print(y6 < x6); # true
print(x6 < y6); # false
print(y6 > x6); # false
print(y6 != x6); # true
print(x6 != y6); # true
print(x6 == y6); # false
print(y6 == x6); # false
# float64
var x7 = 3.0;
var y7 = 2.0;
print(x7 > y7); # true
print(y7 < x7); # true
print(x7 < y7); # false
print(y7 > x7); # false
print(y7 != x7); # true
print(x7 != y7); # true
print(x7 == y7); # false
print(y7 == x7); # false
# float32
var x8 = 3'f32;
var y8 = 2'f32;
print(x8 > y8); # true
print(y8 < x8); # true
print(x8 < y8); # false
print(y8 > x8); # false
print(y8 != x8); # true
print(x8 != y8); # true
print(x8 == y8); # false
print(y8 == x8); # false