summaryrefslogtreecommitdiff
path: root/check.lua
diff options
context:
space:
mode:
Diffstat (limited to 'check.lua')
-rw-r--r--check.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/check.lua b/check.lua
index 36b8e2f..8a2d200 100644
--- a/check.lua
+++ b/check.lua
@@ -21,7 +21,16 @@ local function run(bin, args, opts, timeout)
end
local home = assert(uv.fs_mkdtemp('/private/tmp/panto-agy-XXXXXX'))
local function check()
- local usage=dofile(root..'/acp.lua').usage
+ local acp_mod=dofile(root..'/acp.lua'); local usage=acp_mod.usage
+ local function cut(text,room)
+ local head,tail=acp_mod.history_split(text,room)
+ assert(head..tail==text and #tail<=math.max(room,0) and utf8.len(head) and utf8.len(tail),'bad history split'); return head,tail
+ end
+ local entries={}; for i=1,40 do entries[i]=('[User]: line %02d '):format(i)..('\u{E9}'):rep(i % 7) end
+ local head,tail=cut(table.concat(entries,'\n\n'),200)
+ assert(head:sub(-2)=='\n\n' and tail:sub(1,7)=='[User]:' and #tail>100,'expected an entry-aligned cut')
+ assert(#select(2,cut(('\u{754C}'):rep(100),10))==9) -- three-byte characters stay whole
+ assert(cut('abc',10)=='' and cut('',10)=='' and cut('abc',0)=='abc' and select(2,cut('[a]\n\n[b]',3))=='[b]')
local u={inputTokens=155,outputTokens=41,thoughtTokens=8,cachedReadTokens=55,cachedWriteTokens=10,totalTokens=196}
local v=usage(u); assert(v.input==90 and v.output==41 and v.cache_read==55 and v.cache_write==10 and v.reasoning==8)
u.totalTokens=261; assert(usage(u).input==155); u.totalTokens=99; assert(not usage(u) and not usage({}) and not usage(nil))
@@ -47,6 +56,8 @@ protocol="antigravity-acp"
]])
write(cfg .. '/models.toml', '[antigravity.fast]\nmodel="gemini-test"\ninput=10.0\noutput=10.0\ncache_read=1.0\ncache_write=10.0\n')
write(cfg .. '/SYSTEM.md', 'Short answers.')
+ local filler={}; for i=1,1900 do filler[i]=('filler line %04d abcdefghij'):format(i) end
+ write(cfg .. '/history-filler.txt', table.concat(filler,'\n'))
local exe = home .. '/agy'
assert(uv.fs_symlink(panto, home .. '/panto')) -- short, space-free shebang path
write(exe, '#!' .. home .. '/panto lua\n' .. read(root .. '/tests/fake-agy.lua'))