diff options
Diffstat (limited to 'libgo/go/go/types/testdata/const0.src')
-rw-r--r-- | libgo/go/go/types/testdata/const0.src | 215 |
1 files changed, 0 insertions, 215 deletions
diff --git a/libgo/go/go/types/testdata/const0.src b/libgo/go/go/types/testdata/const0.src deleted file mode 100644 index a2ca344c78..0000000000 --- a/libgo/go/go/types/testdata/const0.src +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// constant declarations - -package const0 - -// constants declarations must be initialized by constants -var x = 0 -const c0 = x /* ERROR "not constant" */ - -// untyped constants -const ( - // boolean values - ub0 = false - ub1 = true - ub2 = 2 < 1 - ub3 = ui1 == uf1 - ub4 = true /* ERROR "cannot convert" */ == 0 - - // integer values - ui0 = 0 - ui1 = 1 - ui2 = 42 - ui3 = 3141592653589793238462643383279502884197169399375105820974944592307816406286 - ui4 = -10 - - ui5 = ui0 + ui1 - ui6 = ui1 - ui1 - ui7 = ui2 * ui1 - ui8 = ui3 / ui3 - ui9 = ui3 % ui3 - - ui10 = 1 / 0 /* ERROR "division by zero" */ - ui11 = ui1 / 0 /* ERROR "division by zero" */ - ui12 = ui3 / ui0 /* ERROR "division by zero" */ - ui13 = 1 % 0 /* ERROR "division by zero" */ - ui14 = ui1 % 0 /* ERROR "division by zero" */ - ui15 = ui3 % ui0 /* ERROR "division by zero" */ - - ui16 = ui2 & ui3 - ui17 = ui2 | ui3 - ui18 = ui2 ^ ui3 - - // floating point values - uf0 = 0. - uf1 = 1. - uf2 = 4.2e1 - uf3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286 - uf4 = 1e-1 - - uf5 = uf0 + uf1 - uf6 = uf1 - uf1 - uf7 = uf2 * uf1 - uf8 = uf3 / uf3 - uf9 = uf3 /* ERROR "not defined" */ % uf3 - - uf10 = 1 / 0 /* ERROR "division by zero" */ - uf11 = uf1 / 0 /* ERROR "division by zero" */ - uf12 = uf3 / uf0 /* ERROR "division by zero" */ - - uf16 = uf2 /* ERROR "not defined" */ & uf3 - uf17 = uf2 /* ERROR "not defined" */ | uf3 - uf18 = uf2 /* ERROR "not defined" */ ^ uf3 - - // complex values - uc0 = 0.i - uc1 = 1.i - uc2 = 4.2e1i - uc3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286i - uc4 = 1e-1i - - uc5 = uc0 + uc1 - uc6 = uc1 - uc1 - uc7 = uc2 * uc1 - uc8 = uc3 / uc3 - uc9 = uc3 /* ERROR "not defined" */ % uc3 - - uc10 = 1 / 0 /* ERROR "division by zero" */ - uc11 = uc1 / 0 /* ERROR "division by zero" */ - uc12 = uc3 / uc0 /* ERROR "division by zero" */ - - uc16 = uc2 /* ERROR "not defined" */ & uc3 - uc17 = uc2 /* ERROR "not defined" */ | uc3 - uc18 = uc2 /* ERROR "not defined" */ ^ uc3 -) - -type ( - mybool bool - myint int - myfloat float64 - mycomplex complex128 -) - -// typed constants -const ( - // boolean values - tb0 bool = false - tb1 bool = true - tb2 mybool = 2 < 1 - tb3 mybool = ti1 /* ERROR "cannot compare" */ == tf1 - - // integer values - ti0 int8 = ui0 - ti1 int32 = ui1 - ti2 int64 = ui2 - ti3 myint = ui3 /* ERROR "overflows" */ - ti4 myint = ui4 - - ti5 = ti0 /* ERROR "mismatched types" */ + ti1 - ti6 = ti1 - ti1 - ti7 = ti2 /* ERROR "mismatched types" */ * ti1 - //ti8 = ti3 / ti3 // TODO(gri) enable this - //ti9 = ti3 % ti3 // TODO(gri) enable this - - ti10 = 1 / 0 /* ERROR "division by zero" */ - ti11 = ti1 / 0 /* ERROR "division by zero" */ - ti12 = ti3 /* ERROR "mismatched types" */ / ti0 - ti13 = 1 % 0 /* ERROR "division by zero" */ - ti14 = ti1 % 0 /* ERROR "division by zero" */ - ti15 = ti3 /* ERROR "mismatched types" */ % ti0 - - ti16 = ti2 /* ERROR "mismatched types" */ & ti3 - ti17 = ti2 /* ERROR "mismatched types" */ | ti4 - ti18 = ti2 ^ ti5 // no mismatched types error because the type of ti5 is unknown - - // floating point values - tf0 float32 = 0. - tf1 float32 = 1. - tf2 float64 = 4.2e1 - tf3 myfloat = 3.141592653589793238462643383279502884197169399375105820974944592307816406286 - tf4 myfloat = 1e-1 - - tf5 = tf0 + tf1 - tf6 = tf1 - tf1 - tf7 = tf2 /* ERROR "mismatched types" */ * tf1 - // tf8 = tf3 / tf3 // TODO(gri) enable this - tf9 = tf3 /* ERROR "not defined" */ % tf3 - - tf10 = 1 / 0 /* ERROR "division by zero" */ - tf11 = tf1 / 0 /* ERROR "division by zero" */ - tf12 = tf3 /* ERROR "mismatched types" */ / tf0 - - tf16 = tf2 /* ERROR "mismatched types" */ & tf3 - tf17 = tf2 /* ERROR "mismatched types" */ | tf3 - tf18 = tf2 /* ERROR "mismatched types" */ ^ tf3 - - // complex values - tc0 = 0.i - tc1 = 1.i - tc2 = 4.2e1i - tc3 = 3.141592653589793238462643383279502884197169399375105820974944592307816406286i - tc4 = 1e-1i - - tc5 = tc0 + tc1 - tc6 = tc1 - tc1 - tc7 = tc2 * tc1 - tc8 = tc3 / tc3 - tc9 = tc3 /* ERROR "not defined" */ % tc3 - - tc10 = 1 / 0 /* ERROR "division by zero" */ - tc11 = tc1 / 0 /* ERROR "division by zero" */ - tc12 = tc3 / tc0 /* ERROR "division by zero" */ - - tc16 = tc2 /* ERROR "not defined" */ & tc3 - tc17 = tc2 /* ERROR "not defined" */ | tc3 - tc18 = tc2 /* ERROR "not defined" */ ^ tc3 -) - -// initialization cycles -const ( - a /* ERROR "cycle" */ = a - b /* ERROR "cycle" */ , c /* ERROR "cycle" */, d, e = e, d, c, b // TODO(gri) should only have one cycle error - f float64 = d -) - -// multiple initialization -const ( - a1, a2, a3 = 7, 3.1415926, "foo" - b1, b2, b3 = b3, b1, 42 - _p0 = assert(a1 == 7) - _p1 = assert(a2 == 3.1415926) - _p2 = assert(a3 == "foo") - _p3 = assert(b1 == 42) - _p4 = assert(b2 == 42) - _p5 = assert(b3 == 42) -) - -// iota -const ( - iota0 = iota - iota1 = iota - iota2 = iota*2 - _a0 = assert(iota0 == 0) - _a1 = assert(iota1 == 1) - _a2 = assert(iota2 == 4) - iota6 = iota*3 - - iota7 - iota8 - _a3 = assert(iota7 == 21) - _a4 = assert(iota8 == 24) -) - -const ( - _b0 = iota - _b1 = assert(iota + iota2 == 5) -) - -// special cases -const ( - _n0 = nil /* ERROR "invalid constant type" */ - _n1 = [ /* ERROR "not constant" */ ]int{} -)
\ No newline at end of file |