@@ -18,14 +18,6 @@ local tbl = mods.tbl
1818local tbl_keys = tbl .keys
1919local fmt = string.format
2020
21- local function with_env (env , fn )
22- stub (os , " getenv" , function (name )
23- return env [name ]
24- end )
25- fn ()
26- os.getenv :revert () --- @diagnostic disable-line : undefined-field
27- end
28-
2921describe (" mods.ntpath" , function ()
3022 local cwd = lfs .currentdir ()
3123
@@ -517,6 +509,30 @@ describe("mods.ntpath", function()
517509 { " ~" , { [[ C:\Users\eric]] }},
518510 { " ~test" , { nil , " home directory for user is not set" }},
519511 }
512+ },
513+ expandvars = {
514+ {
515+ env = { foo = " bar" , [" {foo" ] = " baz1" , [" {foo}" ] = " baz2" },
516+ { " foo" , { " foo" }},
517+ { " $foo bar" , { " bar bar" }},
518+ { " ${foo}bar" , { " barbar" }},
519+ { " $[foo]bar" , { " $[foo]bar" }},
520+ { " $bar bar" , { " $bar bar" }},
521+ { " $?bar" , { " $?bar" }},
522+ { " $foo}bar" , { " bar}bar" }},
523+ { " ${foo" , { " ${foo" }},
524+ { " ${{foo}}" , { " baz1}" }},
525+ { " $foo$foo" , { " barbar" }},
526+ { " $bar$bar" , { " $bar$bar" }},
527+ { " %foo% bar" , { " bar bar" }},
528+ { " %foo%bar" , { " barbar" }},
529+ { " %foo%%foo%" , { " barbar" }},
530+ { " %%foo%%foo%foo%" , { " %foo%foobar" }},
531+ { " %?bar%" , { " %?bar%" }},
532+ { " %foo%%bar" , { " bar%bar" }},
533+ { " '%foo%'%bar" , { " '%foo%'%bar" }},
534+ { " bar'%foo%" , { " bar'%foo%" }},
535+ },
520536 }
521537 }
522538
0 commit comments