- fixed issued with function declarations/function literals
- added more tests and fixed existing tests
SVN=118167
package main
func main() {
- [ ' ',
+ []int(
+ ' ',
'a',
'ä',
'本',
'\ubabe',
'\U0123ABCD',
'\Ucafebabe'
- ]
+ );
}
package main
func main() {
- [ 0.,
+ []float(
+ 0.,
+10.,
-210.,
0.0E123,
+10.01e234,
-210.012e345
- ]
+ );
}
package main
func main() {
- [ 0,
+ []int(
+ 0,
123,
0123,
0000,
0x123,
0X0,
0X123
- ];
+ );
}
package main
func main() {
- [ "",
+ []string(
+ "",
" ",
"'`",
"a",
`\a\b\f\n\r\t\v\\\'\"`,
`\000\123\x00\xca\xFE\u0123\ubabe\U0123ABCD\Ucafebabe`,
`\x\u\U\`
- ]
+ );
}
var x float
}
foo: // a label
- switch {
+ var j int;
+ switch y := 0; true {
case i < y:
fallthrough;
case i < j:
--- /dev/null
+// $G $F.go && $L $F.$A && ./$A.out
+
+// Copyright 2009 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.
+
+package main
+
+// brainfuck
+
+func main() {
+ var a [30000]byte;
+ prog := "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.";
+ p := 0;
+ pc := 0;
+ for {
+ switch prog[pc] {
+ case '>':
+ p++;
+ case '<':
+ p--;
+ case '+':
+ a[p]++;
+ case '-':
+ a[p]--;
+ case '.':
+ print string(a[p]);
+ case '[':
+ if a[p] == 0 {
+ for nest := 1; nest > 0; pc++ {
+ if prog[pc+1] == ']' {
+ nest--;
+ }
+ if prog[pc+1] == '[' {
+ nest++;
+ }
+ }
+ }
+ case ']':
+ if a[p] != 0 {
+ for nest := -1; nest < 0; pc-- {
+ if prog[pc-1] == ']' {
+ nest--;
+ }
+ if prog[pc-1] == '[' {
+ nest++;
+ }
+ }
+ }
+ default:
+ return;
+ }
+ pc++;
+ }
+}