Skip to content

Commit 4d936ca

Browse files
authored
Merge pull request #1 from henriman/sif-private-topology-underlay
Verify `private/topology/underlay`
2 parents eaed1c5 + b4084b5 commit 4d936ca

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

private/topology/underlay/defs.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ const (
4747
EndhostPort = 30041
4848
)
4949

50-
func (o Type) String() string {
50+
// @ requires low(o)
51+
// @ requires o == UDPIPv4 || o == UDPIPv6 || o == UDPIPv46
52+
// @ ensures low(res)
53+
func (o Type) String() (res string) {
5154
switch o {
5255
case UDPIPv4:
5356
return UDPIPv4Name
@@ -56,11 +59,14 @@ func (o Type) String() string {
5659
case UDPIPv46:
5760
return UDPIPv46Name
5861
default:
62+
// @ Unreachable()
5963
return fmt.Sprintf("UNKNOWN (%d)", o)
6064
}
6165
}
6266

63-
func TypeFromString(s string) (Type, error) {
67+
// @ requires low(s)
68+
// @ ensures low(t) && low(err != nil)
69+
func TypeFromString(s string) (t Type, err error) {
6470
switch strings.ToLower(s) {
6571
case strings.ToLower(UDPIPv4Name):
6672
return UDPIPv4, nil
@@ -94,7 +100,9 @@ func (ot Type) MarshalJSON() ([]byte, error) {
94100
return json.Marshal(ot.String())
95101
}
96102

97-
func (ot Type) IsUDP() bool {
103+
// @ requires low(ot)
104+
// @ ensures low(res)
105+
func (ot Type) IsUDP() (res bool) {
98106
switch ot {
99107
case UDPIPv4, UDPIPv6, UDPIPv46:
100108
return true

verification/dependencies/strings/strings.gobra

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ decreases _
111111
func ToUpper(s string) string
112112

113113
// ToLower returns s with all Unicode letters mapped to their lower case.
114+
ensures low(s) ==> low(res)
114115
decreases _
115-
func ToLower(s string) string
116+
func ToLower(s string) (res string)
116117

117118
// ToTitle returns a copy of the string s with all Unicode letters mapped to
118119
// their Unicode title case.

0 commit comments

Comments
 (0)