forked from lune-org/lune
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix casting and add casting test (lune-org#243)
- Loading branch information
Showing
5 changed files
with
39 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
local ffi = require("@lune/ffi") | ||
|
||
local floatBox = ffi.f32:box(1.2) | ||
local intBox = ffi.box(ffi.i32.size) | ||
|
||
ffi.f32:cast(ffi.i32, floatBox, intBox) | ||
|
||
local castedInt = ffi.i32:readData(intBox) | ||
|
||
assert( | ||
castedInt == 1 and ffi.isInteger(castedInt), | ||
"castedInt == 1 and ffi.isInteger(castedInt) assersion failed" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
--!nocheck | ||
--!nolint | ||
|
||
local ffi = require("@lune/ffi") | ||
|
||
local int = 0b1 | ||
local float = 0.5 | ||
|
||
assert(ffi.isInteger(int) == true, "ffi.isInteger(int) == true failed") | ||
assert(ffi.isInteger(float) == false, "ffi.isInteger(float) == false failed") | ||
assert(ffi.isInteger(int) == true, "ffi.isInteger(int) == true assersion failed") | ||
assert(ffi.isInteger(float) == false, "ffi.isInteger(float) == false assersion failed") |