summaryrefslogtreecommitdiff
path: root/test/turing.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2012-01-18 13:20:55 -0800
committerIan Lance Taylor <iant@golang.org>2012-01-18 13:20:55 -0800
commit470dba534031ddc3d4deb45366e745cb434a9ef7 (patch)
tree8b77e90e43c1f3d057cd607b1bd090e38c4d041d /test/turing.go
parenteada3347b2ed966e6154e95575b19eff12a328de (diff)
downloadgo-470dba534031ddc3d4deb45366e745cb434a9ef7.tar.gz
test: gofmt a few tests
I'm planning to change these tests, but the gofmt changes are fairly extensive, so I'm separating the gofmt changes from the substantive changes. R=golang-dev, rsc, r CC=golang-dev http://codereview.appspot.com/5557052
Diffstat (limited to 'test/turing.go')
-rw-r--r--test/turing.go49
1 files changed, 25 insertions, 24 deletions
diff --git a/test/turing.go b/test/turing.go
index 0af39de8b..9d3f3a669 100644
--- a/test/turing.go
+++ b/test/turing.go
@@ -10,15 +10,16 @@ package main
var p, pc int
var a [30000]byte
+
const prog = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.!"
func scan(dir int) {
for nest := dir; dir*nest > 0; pc += dir {
switch prog[pc+dir] {
- case ']':
- nest--
- case '[':
- nest++
+ case ']':
+ nest--
+ case '[':
+ nest++
}
}
}
@@ -26,26 +27,26 @@ func scan(dir int) {
func main() {
for {
switch prog[pc] {
- case '>':
- p++
- case '<':
- p--
- case '+':
- a[p]++
- case '-':
- a[p]--
- case '.':
- print(string(a[p]))
- case '[':
- if a[p] == 0 {
- scan(1)
- }
- case ']':
- if a[p] != 0 {
- scan(-1)
- }
- default:
- return
+ case '>':
+ p++
+ case '<':
+ p--
+ case '+':
+ a[p]++
+ case '-':
+ a[p]--
+ case '.':
+ print(string(a[p]))
+ case '[':
+ if a[p] == 0 {
+ scan(1)
+ }
+ case ']':
+ if a[p] != 0 {
+ scan(-1)
+ }
+ default:
+ return
}
pc++
}