Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / lib / python2.4 / test / test___future__.py
CommitLineData
86530b38
AT
1#! /usr/bin/env python
2from test.test_support import verbose, verify
3from types import TupleType, StringType, IntType
4import __future__
5
6GOOD_SERIALS = ("alpha", "beta", "candidate", "final")
7
8features = __future__.all_feature_names
9
10# Verify that all_feature_names appears correct.
11given_feature_names = features[:]
12for name in dir(__future__):
13 obj = getattr(__future__, name, None)
14 if obj is not None and isinstance(obj, __future__._Feature):
15 verify(name in given_feature_names,
16 "%r should have been in all_feature_names" % name)
17 given_feature_names.remove(name)
18verify(len(given_feature_names) == 0,
19 "all_feature_names has too much: %r" % given_feature_names)
20del given_feature_names
21
22for feature in features:
23 value = getattr(__future__, feature)
24 if verbose:
25 print "Checking __future__ ", feature, "value", value
26
27 optional = value.getOptionalRelease()
28 mandatory = value.getMandatoryRelease()
29
30 verify(type(optional) is TupleType, "optional isn't tuple")
31 verify(len(optional) == 5, "optional isn't 5-tuple")
32 major, minor, micro, level, serial = optional
33 verify(type(major) is IntType, "optional major isn't int")
34 verify(type(minor) is IntType, "optional minor isn't int")
35 verify(type(micro) is IntType, "optional micro isn't int")
36 verify(isinstance(level, basestring), "optional level isn't string")
37 verify(level in GOOD_SERIALS,
38 "optional level string has unknown value")
39 verify(type(serial) is IntType, "optional serial isn't int")
40
41 verify(type(mandatory) is TupleType or
42 mandatory is None, "mandatory isn't tuple or None")
43 if mandatory is not None:
44 verify(len(mandatory) == 5, "mandatory isn't 5-tuple")
45 major, minor, micro, level, serial = mandatory
46 verify(type(major) is IntType, "mandatory major isn't int")
47 verify(type(minor) is IntType, "mandatory minor isn't int")
48 verify(type(micro) is IntType, "mandatory micro isn't int")
49 verify(isinstance(level, basestring), "mandatory level isn't string")
50 verify(level in GOOD_SERIALS,
51 "mandatory serial string has unknown value")
52 verify(type(serial) is IntType, "mandatory serial isn't int")
53 verify(optional < mandatory,
54 "optional not less than mandatory, and mandatory not None")
55
56 verify(hasattr(value, "compiler_flag"),
57 "feature is missing a .compiler_flag attr")
58 verify(type(getattr(value, "compiler_flag")) is IntType,
59 ".compiler_flag isn't int")