Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs vs spaces #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions engine/tests/demo/leetcode5.gos
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func main() {
//t(1000)
}
//assert(j == 10)
result := longestPalindrome2(s)
assert(result == "aaabbbaaabbbaaa")
assert(result == "aaabbbaaabbbaaa")


//assert(longestPalindrome("aa") == "aa")
Expand Down
4 changes: 2 additions & 2 deletions engine/tests/group1/closure4.gos
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ func tt() {
c := 3
return func()int {
d := 2
return a + 1 + c + d
return a + 1 + c + d
}
}
e := func() int {
Expand All @@ -26,7 +26,7 @@ func main() {
c := 3
return func()int {
d := 2
return a + 1 + c + d
return a + 1 + c + d
}
}
e := func() int {
Expand Down
14 changes: 7 additions & 7 deletions engine/tests/group1/defer.gos
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ package main


import (
"fmt"
"fmt"
)

func f() (result int) {
defer func() {
// result is accessed after it was set to 6 by the return statement
result *= 7
}()
return 6
defer func() {
// result is accessed after it was set to 6 by the return statement
result *= 7
}()
return 6
}

func main() {
assert(f() == 42)
fmt.Println(f())

for i := 0; i <= 3; i++ {
defer fmt.Println(i)
defer fmt.Println(i)
}

}
46 changes: 23 additions & 23 deletions engine/tests/group1/map1.gos
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@ package main


func a () (int, int) {
return 6,7
return 6,7
}

func b() int {
return 8
return 8
}

func commaOk() {

var i interface{} = "hello"

var i interface{} = "hello"

s, ok := i.(string)
assert(ok)
assert(s == "hello")

s1 := i.(string)
assert(s1 == "hello")

s, ok := i.(string)
assert(ok)
assert(s == "hello")

s1 := i.(string)
assert(s1 == "hello")


m := map[int]int{1:10, 2:20}
int1, ok := m[1]
assert(int1 == 10)
assert(ok)
int2 := m[2]
assert(int2 == 20)

t1, t2 := a()
assert(t1 == 6)
assert(t2 == 7)
t3 := b()
assert(t3 == 8)

m := map[int]int{1:10, 2:20}
int1, ok := m[1]
assert(int1 == 10)
assert(ok)
int2 := m[2]
assert(int2 == 20)

t1, t2 := a()
assert(t1 == 6)
assert(t2 == 7)
t3 := b()
assert(t3 == 8)

t01, t02 := 33, m[2]
assert(t01 == 33)
assert(t02 == 20)
assert(t02 == 20)
}

func main() {
Expand Down
6 changes: 3 additions & 3 deletions engine/tests/group1/pkg.gos
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ func main() {
}

func fa () (int, int) {
assert(8 == fb())
return 6,7
assert(8 == fb())
return 6,7
}

func fb() int {
return 8
return 8
}
2 changes: 1 addition & 1 deletion engine/tests/group1/type.gos
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Add func(a int, b int) int

func main() {
type S2 struct {i int}
var s1 S1
var s1 S1
//var s2 S2

s1.Inc()
Expand Down
50 changes: 25 additions & 25 deletions engine/tests/group1/typeswitch.gos
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package main

import (
"fmt"
"fmt"
)


type S1 struct {i int; j int}

func typeName(v interface{}) string {
switch v.(type) {
case int:
return "int"
case string:
return "string"
switch v.(type) {
case int:
return "int"
case string:
return "string"
case *S1:
return "S1"
default:
return "unknown"
}
default:
return "unknown"
}
}


func typeName2(v interface{}) string {
kk := 2
switch i := v.(type) {
case int:
switch i := v.(type) {
case int:
assert(i + kk == 890)
return "int"
case string:
return "string"
return "int"
case string:
return "string"
case *S1:
_ = i
_ = i
return "S1"
case []int:
return "[]int"
case map[string]int:
return "map[string]int"
case map[string][]int:
return "map[string][]int"
default:
return "unknown"
}
return "int"
case []int:
return "[]int"
case map[string]int:
return "map[string]int"
case map[string][]int:
return "map[string][]int"
default:
return "unknown"
}
return "int"
}

func main() {
Expand Down
8 changes: 4 additions & 4 deletions engine/tests/group2/case0.gos
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ type TestKey struct {
}

func ptr() (*int, *int) {
i := 100
return &i, &i
i := 100
return &i, &i
}


func main() {

var errNil error
var mapNil map[int]string
//mapNil[1] = "aa"
var mapNil map[int]string
//mapNil[1] = "aa"

m := make(map[int]string)
m[1] = "bb"
Expand Down
6 changes: 3 additions & 3 deletions engine/tests/group2/case3.gos
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

import (
"fmt"
"fmt"
)



func main() {
var v = new(int)
var v = new(int)
var vv = 2
*v = 8
var vvv = *v
Expand All @@ -17,7 +17,7 @@ func main() {

var sa = &A{}

fmt.Println("Hello, playground", v, vv, vvv, s, s1, s3, sa)
fmt.Println("Hello, playground", v, vv, vvv, s, s1, s3, sa)
}

type A []int
Expand Down
6 changes: 3 additions & 3 deletions engine/tests/group2/nil.gos
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"fmt"
"fmt"
)

type III interface{}
Expand All @@ -12,7 +12,7 @@ i int
}

func main() {
//var m []string
//var m []string

var ia interface{}
ia = 8
Expand All @@ -31,7 +31,7 @@ func main() {
a = b
b.i = 55

fmt.Println("Hello, playground", ia, ia == nil, ib, ib == nil, 10, a.i, b.i)
fmt.Println("Hello, playground", ia, ia == nil, ib, ib == nil, 10, a.i, b.i)

c := &a
d := &b
Expand Down
46 changes: 23 additions & 23 deletions engine/tests/group2/unicode0.gos
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
package main

import (
"fmt"
"fmt"
"unicode/utf8"
)

func ExampleDecodeLastRune() {
b := []byte("Hello, 世界")
utf8.DecodeLastRune(b)
b := []byte("Hello, 世界")
utf8.DecodeLastRune(b)

for len(b) > 0 {
r, size := utf8.DecodeLastRune(b)
fmt.Println("%c %v\n", r, size)
for len(b) > 0 {
r, size := utf8.DecodeLastRune(b)
fmt.Println("%c %v\n", r, size)

b = b[:len(b)-size]
}
// Output:
// 界 3
// 世 3
// 1
// , 1
// o 1
// l 1
// l 1
// e 1
// H 1
b = b[:len(b)-size]
}
// Output:
// 界 3
// 世 3
// 1
// , 1
// o 1
// l 1
// l 1
// e 1
// H 1
}


func main() {
ExampleDecodeLastRune()
fmt.Println(utf8.RuneError, "a \n b👌")
s := "\\ \n \\"
fmt.Println(s[0], len(s), s)
fmt.Println(utf8.RuneError, "a \n b👌")
s := "\\ \n \\"
fmt.Println(s[0], len(s), s)
}
8 changes: 4 additions & 4 deletions parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,10 @@ pub struct BadDecl {
//
// Relationship between Tok value and Specs element type:
//
// Token::IMPORT ImportSpec
// Token::CONST ValueSpec
// Token::TYPE TypeSpec
// Token::VAR ValueSpec
// Token::IMPORT ImportSpec
// Token::CONST ValueSpec
// Token::TYPE TypeSpec
// Token::VAR ValueSpec
#[derive(Debug)]
pub struct GenDecl {
pub token_pos: position::Pos,
Expand Down
Loading