Re: Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn
On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote: On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: I feel like I'm missing something, but there has to be an easier way to convert a value into an enum than switching over every possible value: i.e [...] Capitals c =

Re: Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn
On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote: On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote: Any ideas? You can use to! in std.conv: import std.stdio; import std.conv; enum Foo { A = "A", B = "B" } void main() { writeln("A".to

Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn
I feel like I'm missing something, but there has to be an easier way to convert a value into an enum than switching over every possible value: i.e enum Capitals { Indiana = "Indianapolis", Illinois = "Chicago", Ohio = "Columbus" } Capitals enumFromValue(string s) { switch (s) {

Re: Get UDA of unit tests during Runtime.moduleUnitTester

2017-07-26 Thread Matthew Remmel via Digitalmars-d-learn
On Wednesday, 26 July 2017 at 06:47:20 UTC, Jacob Carlborg wrote: On 2017-07-26 05:27, Matthew Remmel wrote: [...] Unless you want to go with the approach Seb suggested, using unit-threaded, you need to recursively iterate the module to get all aggregates using __traits(allMembers) then use

Get UDA of unit tests during Runtime.moduleUnitTester

2017-07-25 Thread Matthew Remmel via Digitalmars-d-learn
I'd like to print out the name given to a unit test via a UDA, as the tests are being ran by the Runtime.moduleUnitTester. I'm working on writing a custom unit test runner. It would seem that the ModuleInfo.unitTest property is an aggregated function of all the individual unit test blocks in a