def testCheckGe(self): check.Ge(2, 1, 'foo') check.Ge(1, 1, 'foo') with self.assertRaisesRegexp(ValueError, 'bar'): check.Ge(0, 1, 'bar') with self.assertRaisesRegexp(RuntimeError, 'baz'): check.Ge(-1, 1, 'baz', RuntimeError)
def ratio(numerator, denominator): check.Ge(numerator, 0) check.Ge(denominator, 0) if denominator > 0: return numerator / denominator elif numerator == 0: return 0.0 # map 0/0 to 0 else: return float('inf') # map x/0 to inf
def token_span(token): check.Ge(token.end, token.start) return (token.start, token.end)