Commit 48c998ec authored by Hugo Moreau's avatar Hugo Moreau

global: added some tests

Currently all tests are passing, except `after.go`, we can create global
variable everywhere in the file, patch will come soon.

 * tests/global/ : Here.
parent 6fe62c10
Pipeline #26352 failed with stage
in 2 minutes and 1 second
package main
import "fmt"
func foo() {
a = 42
}
func main() {
fmt.Println(a)
foo()
fmt.Println(a)
}
var a = 0
package main
import (
"fmt"
)
var a = 2
func foo() {
a = 10
a := 0
n := a
n += 1
}
func main() {
fmt.Println(a)
foo()
fmt.Println(a)
}
package main
import (
"fmt"
)
var a = 2
var b int
func foo(bar int) {
a = bar
a, b, bar = 1, 2, 3
a = b + 42
a -= b + 42
}
func main() {
a = a
fmt.Println(a, b)
foo(0)
fmt.Println(a, b)
}
package main
import (
"fmt"
)
var a = 2
var b int
func foo(bar int) {
a = bar
b = a
a -= b + 42
}
func main() {
fmt.Println(a, b)
foo(0)
fmt.Println(a, b)
}
echo "Test suite for Go2Pins"
echo "======================"
echo
# Valid Tests
output=$(mktemp -t "go2pins-XXXXXX")
exit_value=0
for i in $(ls *.go); do
EXPECTED=$(go run $i)
../../go2pins -f -o normal $i > /dev/null 2>&1
NORMAL=$(go run normal/$i)
../../go2pins -f -o blackbox -blackbox-fn "foo" $i > /dev/null 2>&1
BLACKBOX=$(go run blackbox/$i)
echo $i:
if [ -z $(diff <(echo $EXPECTED) <(echo $NORMAL)) ]; then
echo -e "\tNORMAL:\t\t\e[32mPASS\e[39m"
else
echo -e "\tNORMAL:\t\t\e[31mFAIL\e[39m"
exit_value=2
fi
if [ -z $(diff <(echo $EXPECTED) <(echo $BLACKBOX)) ]; then
echo -e "\tBLACKBOX:\t\e[32mPASS\e[39m"
else
echo -e "\tBLACKBOX:\t\e[31mFAIL\e[39m"
exit_value=2
fi
done
rm -rf normal
rm -rf blackbox
package main
import "fmt"
var a = 0
func foo() {
a = 2
}
func main() {
fmt.Println(a)
foo()
fmt.Println(a)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment