Software / code / prosody
Comparison
spec/util_argparse_spec.lua @ 13766:b11242656300
Merge 13.0->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 11 Mar 2025 18:45:23 +0000 |
| parent | 13762:81856814d74f |
comparison
equal
deleted
inserted
replaced
| 13759:1437d8884899 | 13766:b11242656300 |
|---|---|
| 52 local opts, err = parse({ "--foo"; "bar"; "--baz=moo" }, { value_params = { foo = true; bar = true } }); | 52 local opts, err = parse({ "--foo"; "bar"; "--baz=moo" }, { value_params = { foo = true; bar = true } }); |
| 53 assert.falsy(err); | 53 assert.falsy(err); |
| 54 assert.same({ foo = "bar"; baz = "moo" }, opts); | 54 assert.same({ foo = "bar"; baz = "moo" }, opts); |
| 55 end); | 55 end); |
| 56 | 56 |
| 57 it("supports value arguments in strict mode", function() | |
| 58 local opts, err = parse({ "--foo"; "bar"; "--baz=moo" }, { strict = true, value_params = { foo = true; baz = true } }); | |
| 59 assert.falsy(err); | |
| 60 assert.same({ foo = "bar"; baz = "moo" }, opts); | |
| 61 end); | |
| 62 | |
| 57 it("demands values for value params", function() | 63 it("demands values for value params", function() |
| 58 local opts, err, where = parse({ "--foo" }, { value_params = { foo = true } }); | 64 local opts, err, where = parse({ "--foo" }, { value_params = { foo = true } }); |
| 59 assert.falsy(opts); | 65 assert.falsy(opts); |
| 60 assert.equal("missing-value", err); | 66 assert.equal("missing-value", err); |
| 61 assert.equal("--foo", where); | 67 assert.equal("--foo", where); |