Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F131814
libivy_test.lua
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
libivy_test.lua
View Options
local
libivy
=
require
"ivy.libivy"
it
(
"should run a simple match"
,
function
(
t
)
local
score
=
libivy
.
ivy_match
(
"term"
,
"I am a serch term"
)
if
score
<=
0
then
t
.
error
(
"Score should not be less than 0 found "
..
score
)
end
end
)
it
(
"should find a dot file"
,
function
(
t
)
local
current_dir
=
libivy
.
ivy_cwd
()
local
results
=
libivy
.
ivy_files
(
".github/workflows/ci.yml"
,
current_dir
)
if
results
.
length
~=
2
then
t
.
error
(
"Incorrect number of results found "
..
results
.
length
)
end
if
results
[
2
].
content
~=
".github/workflows/ci.yml"
then
t
.
error
(
"Invalid matches: "
..
results
[
2
].
content
)
end
end
)
it
(
"will allow you to access the length via the metatable"
,
function
(
t
)
local
current_dir
=
libivy
.
ivy_cwd
()
local
results
=
libivy
.
ivy_files
(
".github/workflows/ci.yml"
,
current_dir
)
local
mt
=
getmetatable
(
results
)
if
results
.
length
~=
mt
.
__len
(
results
)
then
t
.
error
"The `length` property does not match the __len metamethod"
end
end
)
it
(
"will create an iterator"
,
function
(
t
)
local
iter
=
libivy
.
ivy_files
(
".github/workflows/ci.yml"
,
libivy
.
ivy_cwd
())
local
mt
=
getmetatable
(
iter
)
if
type
(
mt
[
"__index"
])
~=
"function"
then
t
.
error
"The iterator does not have an __index metamethod"
end
if
type
(
mt
[
"__len"
])
~=
"function"
then
t
.
error
"The iterator does not have an __len metamethod"
end
end
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Apr 6 2026, 6:30 PM (5 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16099
Default Alt Text
libivy_test.lua (1 KB)
Attached To
Mode
R1 ivy.nvim
Attached
Detach File
Event Timeline
Log In to Comment