1#!/usr/libexec/flua 2--- 3-- SPDX-License-Identifier: BSD-2-Clause 4-- 5-- Copyright (c) 2026 Baptiste Daroussin <bapt@FreeBSD.org> 6 7local n = require("nuage") 8 9print(n.dirname("/my/path/path1")) 10 11-- relative path with no directory component: nil 12if n.dirname("path") then 13 n.err('Expecting nil for n.dirname("path")') 14end 15 16-- nil input: nil 17if n.dirname() then 18 n.err("Expecting nil for n.dirname") 19end 20 21-- root path: returns "/" 22if n.dirname("/") ~= "/" then 23 n.err('Expecting "/" for n.dirname("/"), got: ' .. tostring(n.dirname("/"))) 24end 25 26-- top-level directory: returns "/" 27if n.dirname("/foo") ~= "/" then 28 n.err('Expecting "/" for n.dirname("/foo")') 29end 30 31-- deep path 32if n.dirname("/foo/bar/baz") ~= "/foo/bar/" then 33 n.err('Expecting "/foo/bar/" for n.dirname("/foo/bar/baz")') 34end 35