Skip to content

Commit

Permalink
test: make sure constants unit test is testing all types of possible …
Browse files Browse the repository at this point in the history
…values
  • Loading branch information
nawetimebomb committed Oct 10, 2024
1 parent 4430333 commit bc35f3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func createConstant() Constant {
newConst.value.variant = valueT.value
case TOKEN_CONSTANT_FALSE:
newConst.value.kind = BOOLEAN
newConst.value.variant = false
newConst.value.variant = 0
case TOKEN_CONSTANT_INT:
newConst.value.kind = INT64
newConst.value.variant = valueT.value
Expand All @@ -338,7 +338,7 @@ func createConstant() Constant {
newConst.value.variant = valueT.value
case TOKEN_CONSTANT_TRUE:
newConst.value.kind = BOOLEAN
newConst.value.variant = true
newConst.value.variant = 1
default:
if isParsingFunction() {
parser.currentFn.error = true
Expand Down
10 changes: 10 additions & 0 deletions tests/constants.sk
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ using io
; making sure consts are evaluated correctly

const thirty 30
const name "Stanczyk"
const isTrue true
const isFalse false
const oneByte '0'

fn main ()
const twenty 20
const type "compiler"

"30 " print thirty println
"20 " print twenty println
"Stanczyk " print name println
"compiler " print type println
"true " print isTrue println
"false " print isFalse println
"48 " print oneByte println
ret
5 changes: 5 additions & 0 deletions tests/constants.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
30 30
20 20
Stanczyk Stanczyk
compiler compiler
true true
false false
48 48

0 comments on commit bc35f3c

Please sign in to comment.