"Fossies" - the Fresh Open Source Software Archive

Member "meson-0.52.1/test cases/d/9 features/app.d" (9 Dec 2018, 1706 Bytes) of package /linux/privat/meson-0.52.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 import std.stdio;
    3 import std.array : split;
    4 import std.string : strip;
    5 
    6 import extra;
    7 
    8 auto getMenu ()
    9 {
   10     auto foods = import ("food.txt").strip.split ("\n");
   11     return foods;
   12 }
   13 
   14 auto getPeople ()
   15 {
   16     return import ("people.txt").strip.split ("\n");
   17 }
   18 
   19 void main (string[] args)
   20 {
   21     import std.array : join;
   22     import core.stdc.stdlib : exit;
   23 
   24     immutable request = args[1];
   25     if (request == "menu") {
   26         version (No_Menu) {
   27         } else {
   28             writeln ("On the menu: ", getMenu.join (", "));
   29             exit (0);
   30         }
   31     }
   32 
   33     version (With_People) {
   34         if (request == "people") {
   35             writeln ("People: ", getPeople.join (", "));
   36 
   37             // only exit successfully if the second module also had its module version set.
   38             // this checks for issue https://github.com/mesonbuild/meson/issues/3337
   39             if (secondModulePeopleVersionSet ())
   40                 exit (0);
   41             exit (1);
   42         }
   43     }
   44     
   45     version (With_VersionInteger)
   46         version(3) exit(0);
   47 
   48     version (With_Debug)
   49         debug exit(0);
   50     
   51     version (With_DebugInteger)
   52         debug(3) exit(0);
   53     
   54     version (With_DebugIdentifier)
   55         debug(DebugIdentifier) exit(0);
   56     
   57     version (With_DebugAll) {
   58         int dbg = 0;
   59         debug dbg++;
   60         debug(2) dbg++;
   61         debug(3) dbg++;
   62         debug(4) dbg++;
   63         debug(DebugIdentifier) dbg++;
   64         
   65         if (dbg == 5)
   66             exit(0);
   67     }
   68 
   69     // we fail here
   70     exit (1);
   71 }
   72 
   73 unittest
   74 {
   75     writeln ("TEST");
   76     import core.stdc.stdlib : exit;
   77 
   78     writeln(getMenu);
   79     assert (getMenu () == ["Spam", "Eggs", "Spam", "Baked Beans", "Spam", "Spam"]);
   80 
   81     exit (0);
   82 }