1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Regression for #37: a table must hold well past the old ~1M entry cap.
//!
//! Before the fix, any table that grew beyond 1,048,576 entries failed with
//! "not enough memory" regardless of available memory. These build tables an
//! order of magnitude larger and assert they succeed.
use omnilua::Lua;
#[test]
fn two_million_entry_array_builds() {
let lua = Lua::new();
let n: i64 = lua
.load(
r#"
local t = {}
for i = 1, 2000000 do t[i] = i end
return #t
"#,
)
.eval()
.expect("a 2M-element array must build");
assert_eq!(n, 2_000_000);
}
#[test]
fn two_million_string_keys_build() {
let lua = Lua::new();
let n: i64 = lua
.load(
r#"
local t = {}
for i = 1, 2000000 do t["k" .. i] = i end
local c = 0
for _ in pairs(t) do c = c + 1 end
return c
"#,
)
.eval()
.expect("a 2M-key hash table must build");
assert_eq!(n, 2_000_000);
}