MCPcopy Index your code
hub / github.com/yuin/gopher-lua / TestOsWrite

Function TestOsWrite

oslib_test.go:8–33  ·  view source on GitHub ↗

correctly gc-ed. There was a bug in gopher lua where local vars were not being gc-ed in all circumstances.

(t *testing.T)

Source from the content-addressed store, hash-verified

6
7// correctly gc-ed. There was a bug in gopher lua where local vars were not being gc-ed in all circumstances.
8func TestOsWrite(t *testing.T) {
9 s := `
10 local function write(filename, content)
11 local f = assert(io.open(filename, "w"))
12 f:write(content)
13 assert(f:close())
14 end
15
16 local filename = os.tmpname()
17 write(filename, "abc")
18 write(filename, "d")
19 local f = assert(io.open(filename, "r"))
20 local content = f:read("*all"):gsub("%s+", "")
21 f:close()
22 os.remove(filename)
23 local expected = "d"
24 if content ~= expected then
25 error(string.format("Invalid content: Expecting \"%s\", got \"%s\"", expected, content))
26 end
27`
28 L := NewState()
29 defer L.Close()
30 if err := L.DoString(s); err != nil {
31 t.Error(err)
32 }
33}

Callers

nothing calls this directly

Calls 4

DoStringMethod · 0.80
NewStateFunction · 0.70
ErrorMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…