PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/expect

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
expect
Namespace
g17khqpukees4237dtn3astzapmp462vjhsz6st4
Files
13 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/g17khqpukees4237dtn3astzapmp462vjhsz6st4/expect
gno
0.9

Files (13)

  • README.mdmarkdown
  • gnomod.tomltoml
  • boolean.gnogno
  • context.gnogno
  • doc.gnogno
  • error.gnogno
  • float.gnogno
  • func.gnogno
  • int.gnogno
  • message.gnogno
  • string.gnogno
  • uint.gnogno
  • value.gnogno
  • boolean.gnogno
    1package expect23import (4	"strconv"56	"gno.land/p/nt/ufmt/v0"7)89// NewBooleanChecker creates a new checker of boolean values10func NewBooleanChecker(ctx Context, value bool) BooleanChecker {11	return BooleanChecker{ctx, value}12}1314// BooleanChecker asserts boolean values.15type BooleanChecker struct {16	ctx   Context17	value bool18}1920// Not negates the next called expectation.21func (c BooleanChecker) Not() BooleanChecker {22	c.ctx.negated = !c.ctx.negated23	return c24}2526// ToEqual asserts that current value is equal to an expected value.27func (c BooleanChecker) ToEqual(v bool) {28	c.ctx.T().Helper()29	c.ctx.CheckExpectation(c.value == v, func(ctx Context) string {30		got := formatBoolean(c.value)31		if !ctx.IsNegated() {32			want := formatBoolean(v)33			return ufmt.Sprintf("Expected values to match\nGot: %s\nWant: %s", got, want)34		}35		return ufmt.Sprintf("Expected values to be different\nGot: %s", got)36	})37}3839// ToBeFalsy asserts that current value is falsy.40func (c BooleanChecker) ToBeFalsy() {41	c.ctx.T().Helper()42	c.ctx.CheckExpectation(!c.value, func(ctx Context) string {43		if !ctx.IsNegated() {44			return "Expected value to be falsy"45		}46		return "Expected value not to be falsy"47	})48}4950// ToBeTruthy asserts that current value is truthy.51func (c BooleanChecker) ToBeTruthy() {52	c.ctx.T().Helper()53	c.ctx.CheckExpectation(c.value, func(ctx Context) string {54		if !ctx.IsNegated() {55			return "Expected value to be truthy"56		}57		return "Expected value not to be truthy"58	})59}6061func asBoolean(value any) (bool, error) {62	if value == nil {63		return false, nil64	}6566	var s string67	switch v := value.(type) {68	case bool:69		return v, nil70	case string:71		s = v72	case []byte:73		s = string(v)74	case Stringer:75		s = v.String()76	default:77		return false, ErrIncompatibleType78	}7980	if s != "" {81		return strconv.ParseBool(s)82	}83	return false, nil84}8586func formatBoolean(value bool) string {87	return strconv.FormatBool(value)88}89

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.