www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14082] New: RedBlackTree unittest fails with custom predicate

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

          Issue ID: 14082
           Summary: RedBlackTree unittest fails with custom predicate less
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: drug2004 bk.ru

import std.container: RedBlackTree;

class Test(T, alias less = "a<b")
{
        alias Container = RedBlackTree!(T, less);
}

unittest
{
    alias Foo = Test!(int);
}

void main() {}

run using rdmd -unittest filename.d

this code causes unittest failure:
std/container/rbtree.d
Lines 846-850:

        static if(less == "a < b")
            auto vals = [1, 2, 3, 4, 5];
        else
            auto vals = [5, 4, 3, 2, 1];
        assert(equal(r, vals)); 

because less is set to "a<b" instead of "a < b" by default, i.e. spaces have
meaning here. What is the best way to fix that?

--
Jan 30 2015