[Issue 18375] std.getopt uses deprecated rwm operations for shared variables

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 5 13:33:24 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18375

--- Comment #1 from Seb <greensunny12 at gmail.com> ---
std.getopt test cases:

1) Passing and "just" triggering deprecation warnings


---
@system unittest
{
    shared real v;
    shared uint i;
    shared string[] arrString;
    shared int[] arrInt;

    auto args = ["program.name",
        "-v=2",
        "-i=10",
        "--arrString=a", "--arrString=b",
        "--arrInt=1", "--arrInt=2",
    ];
    getopt(args,
        "v", &v,
        "i", &i,
        "arrString", &arrString,
        "arrInt", &arrInt,
    );
    assert(v == 2);
    assert(i == 10);

    shared expectedArrString = ["a", "b"];
    assert(arrString == expectedArrString);
    shared expectedArrInt = [1, 2];
    assert(arrInt == expectedArrInt);
}
---

2) Completely failing

---
@system unittest
{
    shared string s;
    shared bool b;
    shared string[string] assocArrayString;
    shared double[string] assocArrayDouble;

    auto args = ["program.name",
        "-s=bar",
        "-b",
        "--assocArrayString=foo=bar,bar=1",
        "--assocArrayDouble=foo=1,bar=2",
    ];
    getopt(args,
        "s", &s,
        "b", &b,
        "assocArrayString", &assocArrayString,
        "assocArrayDouble", &assocArrayDouble,
    );

    assert(s == "bar");
    assert(b == 1);

    shared expectedAssocArrayString = ["foo": "bar", "bar": "1"];
    assert(assocArrayString == expectedAssocArrayString);
    shared expectedAssocArrayDouble = ["foo":1.0, "bar": 2];
    assert(assocArrayDouble == expectedAssocArrayDouble);
}
---

--


More information about the Digitalmars-d-bugs mailing list