From bd25ac2260267abd2181324e1650820da70e5e60 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 May 2010 12:15:49 +0000 Subject: [PATCH] * Print attributes in sorted order. --- src/libexpr/eval.cc | 9 +++++++-- tests/lang/eval-okay-tryeval.exp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 69632eb37..26739faf6 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -41,12 +41,17 @@ std::ostream & operator << (std::ostream & str, Value & v) case tNull: str << "true"; break; - case tAttrs: + case tAttrs: { str << "{ "; + typedef std::map Sorted; + Sorted sorted; foreach (Bindings::iterator, i, *v.attrs) - str << (string) i->first << " = " << i->second.value << "; "; + sorted[i->first] = &i->second.value; + foreach (Sorted::iterator, i, sorted) + str << i->first << " = " << *i->second << "; "; str << "}"; break; + } case tList: str << "[ "; for (unsigned int n = 0; n < v.list.length; ++n) diff --git a/tests/lang/eval-okay-tryeval.exp b/tests/lang/eval-okay-tryeval.exp index c2788b412..2b2e6fa71 100644 --- a/tests/lang/eval-okay-tryeval.exp +++ b/tests/lang/eval-okay-tryeval.exp @@ -1 +1 @@ -{ x = { value = "x"; success = true; }; y = { value = false; success = false; }; z = { value = false; success = false; }; } +{ x = { success = true; value = "x"; }; y = { success = false; value = false; }; z = { success = false; value = false; }; }