Skip to content

Commit 1484270

Browse files
Yury Smolskybradfitz
authored andcommitted
test: restore tests for the reject unsafe code option
Tests in test/safe were neglected after moving to the run.go framework. This change restores them. These tests are skipped for go/types via -+ option. Fixes #25668 Change-Id: I8fe26574a76fa7afa8664c467d7c2e6334f1bba9 Reviewed-on: https://go-review.googlesource.com/124660 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 4370475 commit 1484270

File tree

6 files changed

+31
-46
lines changed

6 files changed

+31
-46
lines changed

test/safe/main.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/safe/nousesafe.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/safe/pkg.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/safe/usesafe.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/unsafereject1.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// errorcheck -u -+
2+
3+
// Copyright 2018 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// Check that we cannot import a package that uses "unsafe" internally
8+
// when -u is supplied.
9+
10+
package main
11+
12+
import "syscall" // ERROR "import unsafe package"
13+
14+
func main() {
15+
print(syscall.Environ())
16+
}

test/unsafereject2.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// errorcheck -u -+
2+
3+
// Copyright 2018 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// Check that we cannot import the "unsafe" package when -u is supplied.
8+
9+
package a
10+
11+
import "unsafe" // ERROR "import package unsafe"
12+
13+
func Float32bits(f float32) uint32 {
14+
return *(*uint32)(unsafe.Pointer(&f))
15+
}

0 commit comments

Comments
 (0)