Fix setting Luau version number in `_VERSION` env var
This commit is contained in:
parent
5a135a331a
commit
16bec29274
|
@ -84,6 +84,11 @@ pub type lua_Alloc = unsafe extern "C" fn(
|
|||
nsize: usize,
|
||||
) -> *mut c_void;
|
||||
|
||||
/// Returns Luau release version (eg. `0.xxx`).
|
||||
pub const fn luau_version() -> Option<&'static str> {
|
||||
option_env!("LUAU_VERSION")
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
//
|
||||
// State manipulation
|
||||
|
|
|
@ -24,7 +24,7 @@ impl Lua {
|
|||
|
||||
// Set `_VERSION` global to include version number
|
||||
// The environment variable `LUAU_VERSION` set by the build script
|
||||
if let Some(version) = option_env!("LUAU_VERSION") {
|
||||
if let Some(version) = ffi::luau_version() {
|
||||
globals.raw_set("_VERSION", format!("Luau {version}"))?;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,16 @@ use std::sync::Arc;
|
|||
|
||||
use mlua::{Compiler, CoverageInfo, Error, Lua, Result, Table, ThreadStatus, Value, VmState};
|
||||
|
||||
#[test]
|
||||
fn test_version() -> Result<()> {
|
||||
let lua = Lua::new();
|
||||
assert!(lua
|
||||
.globals()
|
||||
.get::<_, String>("_VERSION")?
|
||||
.starts_with("Luau 0."));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_require() -> Result<()> {
|
||||
let lua = Lua::new();
|
||||
|
|
Loading…
Reference in New Issue