File: _pristine.lua

package info (click to toggle)
lua-uri 0.1%2B20130926%2Bgit14fa255d-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 408 kB
  • ctags: 332
  • sloc: makefile: 53
file content (36 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download | duplicates (3)
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
require "lunit"

module("test.pristine", lunit.testcase, package.seeall)

function test_no_global_clobbering ()
    local globals = {}
    for key in pairs(_G) do globals[key] = true end

    -- Load all the modules for the different types of URIs, in case any one
    -- of those treads on a global.  I keep them around in a table to make
    -- sure they're all loaded at the same time, just in case that does
    -- anything interesting.
    local schemes = {
        "_login", "_relative", "_util", "data",
        "file", "file.unix", "file.win32",
        "ftp", "http", "https",
        "pop", "rtsp", "rtspu", "telnet",
        "urn", "urn.isbn", "urn.issn", "urn.oid"
    }
    local loaded = {}
    local URI = require "uri"
    for _, name in ipairs(schemes) do
        loaded[name] = require("uri." .. name)
    end

    for key in pairs(_G) do
        lunit.assert_not_nil(globals[key],
                             "global '" .. key .. "' created by lib")
    end
    for key in pairs(globals) do
        lunit.assert_not_nil(_G[key],
                             "global '" .. key .. "' destroyed by lib")
    end
end

-- vi:ts=4 sw=4 expandtab