mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-05 23:31:21 +08:00
Make printers use singular noun for a single element
* python/libstdcxx/v6/printers.py (num_elements): New function. (StdMapPrinter.to_string, StdSetPrinter.to_string) (StdDequePrinter.to_string, Tr1UnorderedSetPrinter.to_string) (Tr1UnorderedMapPrinter.to_string): Use num_elements. * testsuite/libstdc++-prettyprinters/cxx11.cc: Adjust expected results to use singular noun when there is only one element. * testsuite/libstdc++-prettyprinters/debug.cc: Likewise. * testsuite/libstdc++-prettyprinters/debug_cxx11.cc: Likewise. * testsuite/libstdc++-prettyprinters/simple.cc: Likewise. * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise. * testsuite/libstdc++-prettyprinters/tr1.cc: Likewise. From-SVN: r243652
This commit is contained in:
parent
3c760f4a79
commit
d33c00e1ce
@ -1,5 +1,17 @@
|
||||
2016-12-14 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* python/libstdcxx/v6/printers.py (num_elements): New function.
|
||||
(StdMapPrinter.to_string, StdSetPrinter.to_string)
|
||||
(StdDequePrinter.to_string, Tr1UnorderedSetPrinter.to_string)
|
||||
(Tr1UnorderedMapPrinter.to_string): Use num_elements.
|
||||
* testsuite/libstdc++-prettyprinters/cxx11.cc: Adjust expected results
|
||||
to use singular noun when there is only one element.
|
||||
* testsuite/libstdc++-prettyprinters/debug.cc: Likewise.
|
||||
* testsuite/libstdc++-prettyprinters/debug_cxx11.cc: Likewise.
|
||||
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
|
||||
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
|
||||
* testsuite/libstdc++-prettyprinters/tr1.cc: Likewise.
|
||||
|
||||
PR libstdc++/59170
|
||||
* python/libstdcxx/v6/printers.py (StdDebugIteratorPrinter): Use
|
||||
_M_sequence and _M_version to detect invalid iterators.
|
||||
|
@ -508,6 +508,10 @@ class StdDebugIteratorPrinter:
|
||||
itype = self.val.type.template_argument(0)
|
||||
return self.val.cast(itype)
|
||||
|
||||
def num_elements(num):
|
||||
"""Return either "1 element" or "N elements" depending on the argument."""
|
||||
return '1 element' if num == 1 else '%d elements' % num
|
||||
|
||||
class StdMapPrinter:
|
||||
"Print a std::map or std::multimap"
|
||||
|
||||
@ -539,8 +543,8 @@ class StdMapPrinter:
|
||||
self.val = val
|
||||
|
||||
def to_string (self):
|
||||
return '%s with %d elements' % (self.typename,
|
||||
len (RbtreeIterator (self.val)))
|
||||
return '%s with %s' % (self.typename,
|
||||
num_elements(len(RbtreeIterator (self.val))))
|
||||
|
||||
def children (self):
|
||||
rep_type = find_type(self.val.type, '_Rep_type')
|
||||
@ -579,8 +583,8 @@ class StdSetPrinter:
|
||||
self.val = val
|
||||
|
||||
def to_string (self):
|
||||
return '%s with %d elements' % (self.typename,
|
||||
len (RbtreeIterator (self.val)))
|
||||
return '%s with %s' % (self.typename,
|
||||
num_elements(len(RbtreeIterator (self.val))))
|
||||
|
||||
def children (self):
|
||||
rep_type = find_type(self.val.type, '_Rep_type')
|
||||
@ -681,7 +685,7 @@ class StdDequePrinter:
|
||||
|
||||
size = self.buffer_size * delta_n + delta_s + delta_e
|
||||
|
||||
return '%s with %d elements' % (self.typename, long (size))
|
||||
return '%s with %s' % (self.typename, num_elements(long(size)))
|
||||
|
||||
def children(self):
|
||||
start = self.val['_M_impl']['_M_start']
|
||||
@ -795,7 +799,8 @@ class Tr1UnorderedSetPrinter:
|
||||
return self.val['_M_h']
|
||||
|
||||
def to_string (self):
|
||||
return '%s with %d elements' % (self.typename, self.hashtable()['_M_element_count'])
|
||||
count = self.hashtable()['_M_element_count']
|
||||
return '%s with %s' % (self.typename, num_elements(count))
|
||||
|
||||
@staticmethod
|
||||
def format_count (i):
|
||||
@ -820,7 +825,8 @@ class Tr1UnorderedMapPrinter:
|
||||
return self.val['_M_h']
|
||||
|
||||
def to_string (self):
|
||||
return '%s with %d elements' % (self.typename, self.hashtable()['_M_element_count'])
|
||||
count = self.hashtable()['_M_element_count']
|
||||
return '%s with %s' % (self.typename, num_elements(count))
|
||||
|
||||
@staticmethod
|
||||
def flatten (list):
|
||||
|
@ -113,15 +113,15 @@ main()
|
||||
|
||||
std::unordered_set<int> uos;
|
||||
uos.insert(5);
|
||||
// { dg-final { note-test uos {std::unordered_set with 1 elements = {[0] = 5}} } }
|
||||
// { dg-final { note-test uos {std::unordered_set with 1 element = {[0] = 5}} } }
|
||||
std::unordered_set<int> &ruos = uos;
|
||||
// { dg-final { note-test ruos {std::unordered_set with 1 elements = {[0] = 5}} } }
|
||||
// { dg-final { note-test ruos {std::unordered_set with 1 element = {[0] = 5}} } }
|
||||
|
||||
std::unordered_multiset<int> uoms;
|
||||
uoms.insert(5);
|
||||
// { dg-final { note-test uoms {std::unordered_multiset with 1 elements = {[0] = 5}} } }
|
||||
// { dg-final { note-test uoms {std::unordered_multiset with 1 element = {[0] = 5}} } }
|
||||
std::unordered_multiset<int> &ruoms = uoms;
|
||||
// { dg-final { note-test ruoms {std::unordered_multiset with 1 elements = {[0] = 5}} } }
|
||||
// { dg-final { note-test ruoms {std::unordered_multiset with 1 element = {[0] = 5}} } }
|
||||
|
||||
std::unique_ptr<datum> uptr (new datum);
|
||||
uptr->s = "hi bob";
|
||||
|
@ -66,7 +66,7 @@ main()
|
||||
|
||||
std::map<std::string, int> mp;
|
||||
mp["zardoz"] = 23;
|
||||
// { dg-final { note-test mp {std::__debug::map with 1 elements = {["zardoz"] = 23}} } }
|
||||
// { dg-final { note-test mp {std::__debug::map with 1 element = {["zardoz"] = 23}} } }
|
||||
|
||||
std::map<std::string, int>::iterator mpiter = mp.begin();
|
||||
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
|
||||
|
@ -43,13 +43,13 @@ main()
|
||||
// { dg-final { note-test *flstciter {"dee"}} }
|
||||
|
||||
std::unordered_map<std::string, int> um{ {"zardoz", 23} };
|
||||
// { dg-final { note-test um {std::__debug::unordered_map with 1 elements = {["zardoz"] = 23}} } }
|
||||
// { dg-final { note-test um {std::__debug::unordered_map with 1 element = {["zardoz"] = 23}} } }
|
||||
|
||||
std::unordered_map<std::string, int>::iterator umiter = um.begin();
|
||||
// { dg-final { note-test umiter->first {"zardoz"} } }
|
||||
|
||||
std::unordered_set<std::string> us{"barrel"};
|
||||
// { dg-final { note-test us {std::__debug::unordered_set with 1 elements = {[0] = "barrel"}} } }
|
||||
// { dg-final { note-test us {std::__debug::unordered_set with 1 element = {[0] = "barrel"}} } }
|
||||
|
||||
std::unordered_set<std::string>::const_iterator usciter = us.begin();
|
||||
// { dg-final { note-test *usciter {"barrel"} } }
|
||||
|
@ -68,7 +68,7 @@ main()
|
||||
|
||||
std::map<std::string, int> mp;
|
||||
mp["zardoz"] = 23;
|
||||
// { dg-final { note-test mp {std::map with 1 elements = {["zardoz"] = 23}} } }
|
||||
// { dg-final { note-test mp {std::map with 1 element = {["zardoz"] = 23}} } }
|
||||
|
||||
std::map<std::string, int>::iterator mpiter = mp.begin();
|
||||
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
|
||||
|
@ -68,7 +68,7 @@ main()
|
||||
|
||||
std::map<std::string, int> mp;
|
||||
mp["zardoz"] = 23;
|
||||
// { dg-final { note-test mp {std::map with 1 elements = {["zardoz"] = 23}} } }
|
||||
// { dg-final { note-test mp {std::map with 1 element = {["zardoz"] = 23}} } }
|
||||
|
||||
std::map<std::string, int>::iterator mpiter = mp.begin();
|
||||
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
|
||||
|
@ -71,11 +71,11 @@ main()
|
||||
|
||||
std::tr1::unordered_set<int> uos;
|
||||
uos.insert(5);
|
||||
// { dg-final { note-test uos {std::tr1::unordered_set with 1 elements = {[0] = 5}} } }
|
||||
// { dg-final { note-test uos {std::tr1::unordered_set with 1 element = {[0] = 5}} } }
|
||||
|
||||
std::tr1::unordered_multiset<int> uoms;
|
||||
uoms.insert(5);
|
||||
// { dg-final { note-test uoms {std::tr1::unordered_multiset with 1 elements = {[0] = 5}} } }
|
||||
// { dg-final { note-test uoms {std::tr1::unordered_multiset with 1 element = {[0] = 5}} } }
|
||||
|
||||
placeholder(""); // Mark SPOT
|
||||
use(eum);
|
||||
|
Loading…
x
Reference in New Issue
Block a user