How to use Panicked method of types Package

Best Ginkgo code snippet using types.Panicked

list_test.go

Source:list_test.go Github

copy

Full Screen

...544 t.Errorf("Did not panic with illegal size: %s", errStr)545 continue546 }547 if dimsOK && panicked {548 t.Errorf("Panicked with legal size: %s: %v", errStr, err)549 continue550 }551 if !equal(a, aCopy) {552 t.Errorf("First input argument changed in call: %s", errStr)553 }554 if !dimsOK {555 continue556 }557 if !sameAnswer(want, got) {558 t.Errorf("Answer mismatch: %s", errStr)559 }560 }561 }562}563var sizePairs = []struct {564 ar, ac, br, bc int565}{566 {1, 1, 1, 1},567 {6, 6, 6, 6},568 {7, 7, 7, 7},569 {1, 1, 1, 5},570 {1, 1, 5, 1},571 {1, 5, 1, 1},572 {5, 1, 1, 1},573 {5, 5, 5, 1},574 {5, 5, 1, 5},575 {5, 1, 5, 5},576 {1, 5, 5, 5},577 {6, 6, 6, 11},578 {6, 6, 11, 6},579 {6, 11, 6, 6},580 {11, 6, 6, 6},581 {11, 11, 11, 6},582 {11, 11, 6, 11},583 {11, 6, 11, 11},584 {6, 11, 11, 11},585 {1, 1, 5, 5},586 {1, 5, 1, 5},587 {1, 5, 5, 1},588 {5, 1, 1, 5},589 {5, 1, 5, 1},590 {5, 5, 1, 1},591 {6, 6, 11, 11},592 {6, 11, 6, 11},593 {6, 11, 11, 6},594 {11, 6, 6, 11},595 {11, 6, 11, 6},596 {11, 11, 6, 6},597 {1, 1, 17, 11},598 {1, 1, 11, 17},599 {1, 11, 1, 17},600 {1, 17, 1, 11},601 {1, 11, 17, 1},602 {1, 17, 11, 1},603 {11, 1, 1, 17},604 {17, 1, 1, 11},605 {11, 1, 17, 1},606 {17, 1, 11, 1},607 {11, 17, 1, 1},608 {17, 11, 1, 1},609 {6, 6, 1, 11},610 {6, 6, 11, 1},611 {6, 11, 6, 1},612 {6, 1, 6, 11},613 {6, 11, 1, 6},614 {6, 1, 11, 6},615 {11, 6, 6, 1},616 {1, 6, 6, 11},617 {11, 6, 1, 6},618 {1, 6, 11, 6},619 {11, 1, 6, 6},620 {1, 11, 6, 6},621 {6, 6, 17, 1},622 {6, 6, 1, 17},623 {6, 1, 6, 17},624 {6, 17, 6, 1},625 {6, 1, 17, 6},626 {6, 17, 1, 6},627 {1, 6, 6, 17},628 {17, 6, 6, 1},629 {1, 6, 17, 6},630 {17, 6, 1, 6},631 {1, 17, 6, 6},632 {17, 1, 6, 6},633 {6, 6, 17, 11},634 {6, 6, 11, 17},635 {6, 11, 6, 17},636 {6, 17, 6, 11},637 {6, 11, 17, 6},638 {6, 17, 11, 6},639 {11, 6, 6, 17},640 {17, 6, 6, 11},641 {11, 6, 17, 6},642 {17, 6, 11, 6},643 {11, 17, 6, 6},644 {17, 11, 6, 6},645}646func testTwoInputFunc(t *testing.T,647 // name is the name of the function being tested.648 name string,649 // f is the function being tested.650 f func(a, b Matrix) interface{},651 // denseComparison performs the same operation, but using Dense matrices for652 // comparison.653 denseComparison func(a, b *Dense) interface{},654 // sameAnswer compares the result from two different evaluations of the function655 // and returns true if they are the same. The specific function being tested656 // determines the definition of "same". It may mean identical or it may mean657 // approximately equal.658 sameAnswer func(a, b interface{}) bool,659 // legalType returns true if the types of the inputs are legal for the660 // input of the function.661 legalType func(a, b Matrix) bool,662 // legalSize returns true if the sizes are valid for the function.663 legalSize func(ar, ac, br, bc int) bool,664) {665 for _, aMat := range testMatrices {666 for _, bMat := range testMatrices {667 // Loop over all of the size combinations (bigger, smaller, etc.).668 for _, test := range sizePairs {669 // Skip the test if the argument would not be assignable to the670 // method's corresponding input parameter or it is not possible671 // to construct an argument of the requested size.672 if !legalType(aMat, bMat) {673 continue674 }675 if !legalDims(aMat, test.ar, test.ac) {676 continue677 }678 if !legalDims(bMat, test.br, test.bc) {679 continue680 }681 a := makeRandOf(aMat, test.ar, test.ac)682 b := makeRandOf(bMat, test.br, test.bc)683 // Compute the true answer if the sizes are legal.684 dimsOK := legalSize(test.ar, test.ac, test.br, test.bc)685 var want interface{}686 if dimsOK {687 var aDense, bDense Dense688 aDense.Clone(a)689 bDense.Clone(b)690 want = denseComparison(&aDense, &bDense)691 }692 aCopy := makeCopyOf(a)693 bCopy := makeCopyOf(b)694 // Test the method for a zero-value of the receiver.695 aType, aTrans := untranspose(a)696 bType, bTrans := untranspose(b)697 errStr := fmt.Sprintf("%v(%T, %T), size: %#v, atrans %t, btrans %t", name, aType, bType, test, aTrans, bTrans)698 var got interface{}699 panicked, err := panics(func() { got = f(a, b) })700 if !dimsOK && !panicked {701 t.Errorf("Did not panic with illegal size: %s", errStr)702 continue703 }704 if dimsOK && panicked {705 t.Errorf("Panicked with legal size: %s: %v", errStr, err)706 continue707 }708 if !equal(a, aCopy) {709 t.Errorf("First input argument changed in call: %s", errStr)710 }711 if !equal(b, bCopy) {712 t.Errorf("First input argument changed in call: %s", errStr)713 }714 if !dimsOK {715 continue716 }717 if !sameAnswer(want, got) {718 t.Errorf("Answer mismatch: %s", errStr)719 }720 }721 }722 }723}724// testOneInput tests a method that has one matrix input argument725func testOneInput(t *testing.T,726 // name is the name of the method being tested.727 name string,728 // receiver is a value of the receiver type.729 receiver Matrix,730 // method is the generalized receiver.Method(a).731 method func(receiver, a Matrix),732 // denseComparison performs the same operation as method, but with dense733 // matrices for comparison with the result.734 denseComparison func(receiver, a *Dense),735 // legalTypes returns whether the concrete types in Matrix are valid for736 // the method.737 legalType func(a Matrix) bool,738 // legalSize returns whether the matrix sizes are valid for the method.739 legalSize func(ar, ac int) bool,740 // tol is the tolerance for equality when comparing method results.741 tol float64,742) {743 for _, aMat := range testMatrices {744 for _, test := range sizes {745 // Skip the test if the argument would not be assignable to the746 // method's corresponding input parameter or it is not possible747 // to construct an argument of the requested size.748 if !legalType(aMat) {749 continue750 }751 if !legalDims(aMat, test.ar, test.ac) {752 continue753 }754 a := makeRandOf(aMat, test.ar, test.ac)755 // Compute the true answer if the sizes are legal.756 dimsOK := legalSize(test.ar, test.ac)757 var want Dense758 if dimsOK {759 var aDense Dense760 aDense.Clone(a)761 denseComparison(&want, &aDense)762 }763 aCopy := makeCopyOf(a)764 // Test the method for a zero-value of the receiver.765 aType, aTrans := untranspose(a)766 errStr := fmt.Sprintf("%T.%s(%T), size: %#v, atrans %v", receiver, name, aType, test, aTrans)767 zero := makeRandOf(receiver, 0, 0)768 panicked, err := panics(func() { method(zero, a) })769 if !dimsOK && !panicked {770 t.Errorf("Did not panic with illegal size: %s", errStr)771 continue772 }773 if dimsOK && panicked {774 t.Errorf("Panicked with legal size: %s: %v", errStr, err)775 continue776 }777 if !equal(a, aCopy) {778 t.Errorf("First input argument changed in call: %s", errStr)779 }780 if !dimsOK {781 continue782 }783 if !equalApprox(zero, &want, tol, false) {784 t.Errorf("Answer mismatch with zero receiver: %s.\nGot:\n% v\nWant:\n% v\n", errStr, Formatted(zero), Formatted(&want))785 continue786 }787 // Test the method with a non-zero-value of the receiver.788 // The receiver has been overwritten in place so use its size789 // to construct a new random matrix.790 rr, rc := zero.Dims()791 neverZero := makeRandOf(receiver, rr, rc)792 panicked, _ = panics(func() { method(neverZero, a) })793 if panicked {794 t.Errorf("Panicked with non-zero receiver: %s", errStr)795 }796 if !equalApprox(neverZero, &want, tol, false) {797 t.Errorf("Answer mismatch non-zero receiver: %s", errStr)798 }799 // Test with an incorrectly sized matrix.800 switch receiver.(type) {801 default:802 panic("matrix type not coded for incorrect receiver size")803 case *Dense:804 wrongSize := makeRandOf(receiver, rr+1, rc)805 panicked, _ = panics(func() { method(wrongSize, a) })806 if !panicked {807 t.Errorf("Did not panic with wrong number of rows: %s", errStr)808 }809 wrongSize = makeRandOf(receiver, rr, rc+1)810 panicked, _ = panics(func() { method(wrongSize, a) })811 if !panicked {812 t.Errorf("Did not panic with wrong number of columns: %s", errStr)813 }814 case *TriDense, *SymDense:815 // Add to the square size.816 wrongSize := makeRandOf(receiver, rr+1, rc+1)817 panicked, _ = panics(func() { method(wrongSize, a) })818 if !panicked {819 t.Errorf("Did not panic with wrong size: %s", errStr)820 }821 case *Vector:822 // Add to the column length.823 wrongSize := makeRandOf(receiver, rr+1, rc)824 panicked, _ = panics(func() { method(wrongSize, a) })825 if !panicked {826 t.Errorf("Did not panic with wrong number of rows: %s", errStr)827 }828 }829 // The receiver and the input may share a matrix pointer830 // if the type and size of the receiver and one of the831 // arguments match. Test the method works properly832 // when this is the case.833 aMaybeSame := maybeSame(neverZero, a)834 if aMaybeSame {835 aSame := makeCopyOf(a)836 receiver = aSame837 u, ok := aSame.(Untransposer)838 if ok {839 receiver = u.Untranspose()840 }841 preData := underlyingData(receiver)842 panicked, err = panics(func() { method(receiver, aSame) })843 if panicked {844 t.Errorf("Panics when a maybeSame: %s: %v", errStr, err)845 } else {846 if !equalApprox(receiver, &want, tol, false) {847 t.Errorf("Wrong answer when a maybeSame: %s", errStr)848 }849 postData := underlyingData(receiver)850 if !floats.Equal(preData, postData) {851 t.Errorf("Original data slice not modified when a maybeSame: %s", errStr)852 }853 }854 }855 }856 }857}858// testTwoInput tests a method that has two input arguments.859func testTwoInput(t *testing.T,860 // name is the name of the method being tested.861 name string,862 // receiver is a value of the receiver type.863 receiver Matrix,864 // method is the generalized receiver.Method(a, b).865 method func(receiver, a, b Matrix),866 // denseComparison performs the same operation as method, but with dense867 // matrices for comparison with the result.868 denseComparison func(receiver, a, b *Dense),869 // legalTypes returns whether the concrete types in Matrix are valid for870 // the method.871 legalTypes func(a, b Matrix) bool,872 // legalSize returns whether the matrix sizes are valid for the method.873 legalSize func(ar, ac, br, bc int) bool,874 // tol is the tolerance for equality when comparing method results.875 tol float64,876) {877 for _, aMat := range testMatrices {878 for _, bMat := range testMatrices {879 // Loop over all of the size combinations (bigger, smaller, etc.).880 for _, test := range sizePairs {881 // Skip the test if any argument would not be assignable to the882 // method's corresponding input parameter or it is not possible883 // to construct an argument of the requested size.884 if !legalTypes(aMat, bMat) {885 continue886 }887 if !legalDims(aMat, test.ar, test.ac) {888 continue889 }890 if !legalDims(bMat, test.br, test.bc) {891 continue892 }893 a := makeRandOf(aMat, test.ar, test.ac)894 b := makeRandOf(bMat, test.br, test.bc)895 // Compute the true answer if the sizes are legal.896 dimsOK := legalSize(test.ar, test.ac, test.br, test.bc)897 var want Dense898 if dimsOK {899 var aDense, bDense Dense900 aDense.Clone(a)901 bDense.Clone(b)902 denseComparison(&want, &aDense, &bDense)903 }904 aCopy := makeCopyOf(a)905 bCopy := makeCopyOf(b)906 // Test the method for a zero-value of the receiver.907 aType, aTrans := untranspose(a)908 bType, bTrans := untranspose(b)909 errStr := fmt.Sprintf("%T.%s(%T, %T), sizes: %#v, atrans %v, btrans %v", receiver, name, aType, bType, test, aTrans, bTrans)910 zero := makeRandOf(receiver, 0, 0)911 panicked, err := panics(func() { method(zero, a, b) })912 if !dimsOK && !panicked {913 t.Errorf("Did not panic with illegal size: %s", errStr)914 continue915 }916 if dimsOK && panicked {917 t.Errorf("Panicked with legal size: %s: %v", errStr, err)918 continue919 }920 if !equal(a, aCopy) {921 t.Errorf("First input argument changed in call: %s", errStr)922 }923 if !equal(b, bCopy) {924 t.Errorf("Second input argument changed in call: %s", errStr)925 }926 if !dimsOK {927 continue928 }929 wasZero, zero := zero, nil // Nil-out zero so we detect illegal use.930 // NaN equality is allowed because of 0/0 in DivElem test.931 if !equalApprox(wasZero, &want, tol, true) {932 t.Errorf("Answer mismatch with zero receiver: %s", errStr)933 continue934 }935 // Test the method with a non-zero-value of the receiver.936 // The receiver has been overwritten in place so use its size937 // to construct a new random matrix.938 rr, rc := wasZero.Dims()939 neverZero := makeRandOf(receiver, rr, rc)940 panicked, message := panics(func() { method(neverZero, a, b) })941 if panicked {942 t.Errorf("Panicked with non-zero receiver: %s: %s", errStr, message)943 }944 // NaN equality is allowed because of 0/0 in DivElem test.945 if !equalApprox(neverZero, &want, tol, true) {946 t.Errorf("Answer mismatch non-zero receiver: %s", errStr)947 }948 // Test with an incorrectly sized matrix.949 switch receiver.(type) {950 default:951 panic("matrix type not coded for incorrect receiver size")952 case *Dense:953 wrongSize := makeRandOf(receiver, rr+1, rc)954 panicked, _ = panics(func() { method(wrongSize, a, b) })955 if !panicked {956 t.Errorf("Did not panic with wrong number of rows: %s", errStr)...

Full Screen

Full Screen

triangular_test.go

Source:triangular_test.go Github

copy

Full Screen

1package mat642import (3 "math"4 "math/rand"5 "reflect"6 "testing"7 "github.com/gonum/blas"8 "github.com/gonum/blas/blas64"9 "github.com/gonum/matrix"10)11func TestNewTriangular(t *testing.T) {12 for i, test := range []struct {13 data []float6414 n int15 kind matrix.TriKind16 mat *TriDense17 }{18 {19 data: []float64{20 1, 2, 3,21 4, 5, 6,22 7, 8, 9,23 },24 n: 3,25 kind: matrix.Upper,26 mat: &TriDense{27 mat: blas64.Triangular{28 N: 3,29 Stride: 3,30 Uplo: blas.Upper,31 Data: []float64{1, 2, 3, 4, 5, 6, 7, 8, 9},32 Diag: blas.NonUnit,33 },34 cap: 3,35 },36 },37 } {38 tri := NewTriDense(test.n, test.kind, test.data)39 rows, cols := tri.Dims()40 if rows != test.n {41 t.Errorf("unexpected number of rows for test %d: got: %d want: %d", i, rows, test.n)42 }43 if cols != test.n {44 t.Errorf("unexpected number of cols for test %d: got: %d want: %d", i, cols, test.n)45 }46 if !reflect.DeepEqual(tri, test.mat) {47 t.Errorf("unexpected data slice for test %d: got: %v want: %v", i, tri, test.mat)48 }49 }50 for _, kind := range []matrix.TriKind{matrix.Lower, matrix.Upper} {51 panicked, message := panics(func() { NewTriDense(3, kind, []float64{1, 2}) })52 if !panicked || message != matrix.ErrShape.Error() {53 t.Errorf("expected panic for invalid data slice length for upper=%t", kind)54 }55 }56}57func TestTriAtSet(t *testing.T) {58 tri := &TriDense{59 mat: blas64.Triangular{60 N: 3,61 Stride: 3,62 Uplo: blas.Upper,63 Data: []float64{1, 2, 3, 4, 5, 6, 7, 8, 9},64 Diag: blas.NonUnit,65 },66 cap: 3,67 }68 rows, cols := tri.Dims()69 // Check At out of bounds70 for _, row := range []int{-1, rows, rows + 1} {71 panicked, message := panics(func() { tri.At(row, 0) })72 if !panicked || message != matrix.ErrRowAccess.Error() {73 t.Errorf("expected panic for invalid row access N=%d r=%d", rows, row)74 }75 }76 for _, col := range []int{-1, cols, cols + 1} {77 panicked, message := panics(func() { tri.At(0, col) })78 if !panicked || message != matrix.ErrColAccess.Error() {79 t.Errorf("expected panic for invalid column access N=%d c=%d", cols, col)80 }81 }82 // Check Set out of bounds83 for _, row := range []int{-1, rows, rows + 1} {84 panicked, message := panics(func() { tri.SetTri(row, 0, 1.2) })85 if !panicked || message != matrix.ErrRowAccess.Error() {86 t.Errorf("expected panic for invalid row access N=%d r=%d", rows, row)87 }88 }89 for _, col := range []int{-1, cols, cols + 1} {90 panicked, message := panics(func() { tri.SetTri(0, col, 1.2) })91 if !panicked || message != matrix.ErrColAccess.Error() {92 t.Errorf("expected panic for invalid column access N=%d c=%d", cols, col)93 }94 }95 for _, st := range []struct {96 row, col int97 uplo blas.Uplo98 }{99 {row: 2, col: 1, uplo: blas.Upper},100 {row: 1, col: 2, uplo: blas.Lower},101 } {102 tri.mat.Uplo = st.uplo103 panicked, message := panics(func() { tri.SetTri(st.row, st.col, 1.2) })104 if !panicked || message != matrix.ErrTriangleSet.Error() {105 t.Errorf("expected panic for %+v", st)106 }107 }108 for _, st := range []struct {109 row, col int110 uplo blas.Uplo111 orig, new float64112 }{113 {row: 2, col: 1, uplo: blas.Lower, orig: 8, new: 15},114 {row: 1, col: 2, uplo: blas.Upper, orig: 6, new: 15},115 } {116 tri.mat.Uplo = st.uplo117 if e := tri.At(st.row, st.col); e != st.orig {118 t.Errorf("unexpected value for At(%d, %d): got: %v want: %v", st.row, st.col, e, st.orig)119 }120 tri.SetTri(st.row, st.col, st.new)121 if e := tri.At(st.row, st.col); e != st.new {122 t.Errorf("unexpected value for At(%d, %d) after SetTri(%[1]d, %d, %v): got: %v want: %[3]v", st.row, st.col, st.new, e)123 }124 }125}126func TestTriDenseCopy(t *testing.T) {127 for i := 0; i < 100; i++ {128 size := rand.Intn(100)129 r, err := randDense(size, 0.9, rand.NormFloat64)130 if size == 0 {131 if err != matrix.ErrZeroLength {132 t.Fatalf("expected error %v: got: %v", matrix.ErrZeroLength, err)133 }134 continue135 }136 if err != nil {137 t.Fatalf("unexpected error: %v", err)138 }139 u := NewTriDense(size, true, nil)140 l := NewTriDense(size, false, nil)141 for _, typ := range []Matrix{r, (*basicMatrix)(r)} {142 for j := range u.mat.Data {143 u.mat.Data[j] = math.NaN()144 l.mat.Data[j] = math.NaN()145 }146 u.Copy(typ)147 l.Copy(typ)148 for m := 0; m < size; m++ {149 for n := 0; n < size; n++ {150 want := typ.At(m, n)151 switch {152 case m < n: // Upper triangular matrix.153 if got := u.At(m, n); got != want {154 t.Errorf("unexpected upper value for At(%d, %d) for test %d: got: %v want: %v", m, n, i, got, want)155 }156 case m == n: // Diagonal matrix.157 if got := u.At(m, n); got != want {158 t.Errorf("unexpected upper value for At(%d, %d) for test %d: got: %v want: %v", m, n, i, got, want)159 }160 if got := l.At(m, n); got != want {161 t.Errorf("unexpected diagonal value for At(%d, %d) for test %d: got: %v want: %v", m, n, i, got, want)162 }163 case m < n: // Lower triangular matrix.164 if got := l.At(m, n); got != want {165 t.Errorf("unexpected lower value for At(%d, %d) for test %d: got: %v want: %v", m, n, i, got, want)166 }167 }168 }169 }170 }171 }172}173func TestTriTriDenseCopy(t *testing.T) {174 for i := 0; i < 100; i++ {175 size := rand.Intn(100)176 r, err := randDense(size, 1, rand.NormFloat64)177 if size == 0 {178 if err != matrix.ErrZeroLength {179 t.Fatalf("expected error %v: got: %v", matrix.ErrZeroLength, err)180 }181 continue182 }183 if err != nil {184 t.Fatalf("unexpected error: %v", err)185 }186 ur := NewTriDense(size, true, nil)187 lr := NewTriDense(size, false, nil)188 ur.Copy(r)189 lr.Copy(r)190 u := NewTriDense(size, true, nil)191 u.Copy(ur)192 if !equal(u, ur) {193 t.Fatal("unexpected result for U triangle copy of U triangle: not equal")194 }195 l := NewTriDense(size, false, nil)196 l.Copy(lr)197 if !equal(l, lr) {198 t.Fatal("unexpected result for L triangle copy of L triangle: not equal")199 }200 zero(u.mat.Data)201 u.Copy(lr)202 if !isDiagonal(u) {203 t.Fatal("unexpected result for U triangle copy of L triangle: off diagonal non-zero element")204 }205 if !equalDiagonal(u, lr) {206 t.Fatal("unexpected result for U triangle copy of L triangle: diagonal not equal")207 }208 zero(l.mat.Data)209 l.Copy(ur)210 if !isDiagonal(l) {211 t.Fatal("unexpected result for L triangle copy of U triangle: off diagonal non-zero element")212 }213 if !equalDiagonal(l, ur) {214 t.Fatal("unexpected result for L triangle copy of U triangle: diagonal not equal")215 }216 }217}218func TestTriInverse(t *testing.T) {219 for _, kind := range []matrix.TriKind{matrix.Upper, matrix.Lower} {220 for _, n := range []int{1, 3, 5, 9} {221 data := make([]float64, n*n)222 for i := range data {223 data[i] = rand.NormFloat64()224 }225 a := NewTriDense(n, kind, data)226 var tr TriDense227 err := tr.InverseTri(a)228 if err != nil {229 t.Errorf("Bad test: %s", err)230 }231 var d Dense232 d.Mul(a, &tr)233 if !equalApprox(eye(n), &d, 1e-8, false) {234 var diff Dense235 diff.Sub(eye(n), &d)236 t.Errorf("Tri times inverse is not identity. Norm of difference: %v", Norm(&diff, 2))237 }238 }239 }240}241func TestTriMul(t *testing.T) {242 method := func(receiver, a, b Matrix) {243 type MulTrier interface {244 MulTri(a, b Triangular)245 }246 receiver.(MulTrier).MulTri(a.(Triangular), b.(Triangular))247 }248 denseComparison := func(receiver, a, b *Dense) {249 receiver.Mul(a, b)250 }251 legalSizeTriMul := func(ar, ac, br, bc int) bool {252 // Need both to be square and the sizes to be the same253 return ar == ac && br == bc && ar == br254 }255 // The legal types are triangles with the same TriKind.256 // legalTypesTri returns whether both input arguments are Triangular.257 legalTypes := func(a, b Matrix) bool {258 at, ok := a.(Triangular)259 if !ok {260 return false261 }262 bt, ok := b.(Triangular)263 if !ok {264 return false265 }266 _, ak := at.Triangle()267 _, bk := bt.Triangle()268 return ak == bk269 }270 legalTypesLower := func(a, b Matrix) bool {271 legal := legalTypes(a, b)272 if !legal {273 return false274 }275 _, kind := a.(Triangular).Triangle()276 r := kind == matrix.Lower277 return r278 }279 receiver := NewTriDense(3, matrix.Lower, nil)280 testTwoInput(t, "TriMul", receiver, method, denseComparison, legalTypesLower, legalSizeTriMul, 1e-14)281 legalTypesUpper := func(a, b Matrix) bool {282 legal := legalTypes(a, b)283 if !legal {284 return false285 }286 _, kind := a.(Triangular).Triangle()287 r := kind == matrix.Upper288 return r289 }290 receiver = NewTriDense(3, matrix.Upper, nil)291 testTwoInput(t, "TriMul", receiver, method, denseComparison, legalTypesUpper, legalSizeTriMul, 1e-14)292}...

Full Screen

Full Screen

types_test.go

Source:types_test.go Github

copy

Full Screen

...6)7var specStates = []SpecState{8 SpecStatePassed,9 SpecStateTimedOut,10 SpecStatePanicked,11 SpecStateFailed,12 SpecStatePending,13 SpecStateSkipped,14}15func verifySpecSummary(caller func(SpecSummary) bool, trueStates ...SpecState) {16 summary := SpecSummary{}17 trueStateLookup := map[SpecState]bool{}18 for _, state := range trueStates {19 trueStateLookup[state] = true20 summary.State = state21 Ω(caller(summary)).Should(BeTrue())22 }23 for _, state := range specStates {24 if trueStateLookup[state] {25 continue26 }27 summary.State = state28 Ω(caller(summary)).Should(BeFalse())29 }30}31var _ = Describe("Types", func() {32 Describe("IsFailureState", func() {33 It("knows when it is in a failure-like state", func() {34 verifySpecSummary(func(summary SpecSummary) bool {35 return summary.State.IsFailure()36 }, SpecStateTimedOut, SpecStatePanicked, SpecStateFailed)37 })38 })39 Describe("SpecSummary", func() {40 It("knows when it is in a failure-like state", func() {41 verifySpecSummary(func(summary SpecSummary) bool {42 return summary.HasFailureState()43 }, SpecStateTimedOut, SpecStatePanicked, SpecStateFailed)44 })45 It("knows when it passed", func() {46 verifySpecSummary(func(summary SpecSummary) bool {47 return summary.Passed()48 }, SpecStatePassed)49 })50 It("knows when it has failed", func() {51 verifySpecSummary(func(summary SpecSummary) bool {52 return summary.Failed()53 }, SpecStateFailed)54 })55 It("knows when it has panicked", func() {56 verifySpecSummary(func(summary SpecSummary) bool {57 return summary.Panicked()58 }, SpecStatePanicked)59 })60 It("knows when it has timed out", func() {61 verifySpecSummary(func(summary SpecSummary) bool {62 return summary.TimedOut()63 }, SpecStateTimedOut)64 })65 It("knows when it is pending", func() {66 verifySpecSummary(func(summary SpecSummary) bool {67 return summary.Pending()68 }, SpecStatePending)69 })70 It("knows when it is skipped", func() {71 verifySpecSummary(func(summary SpecSummary) bool {72 return summary.Skipped()...

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 defer func() {4 if r := recover(); r != nil {5 fmt.Println("Recovered in f", r)6 debug.PrintStack()7 }8 }()9 panic("PANIC")10}11main.main()12import (13func main() {14 defer func() {15 if r := recover(); r != nil {16 fmt.Println("Recovered in f", r)17 debug.PrintStack()18 }19 }()20 panic("PANIC")21 panic("PANIC")22}23main.main()24import (25func main() {26 defer func() {27 if r := recover(); r != nil {28 fmt.Println("Recovered in f", r)29 debug.PrintStack()30 }31 }()32 defer func() {33 if r := recover(); r != nil {34 fmt.Println("Recovered in f", r)35 debug.PrintStack()36 }37 }()38 panic("PANIC")39 panic("PANIC")40}41main.main()42main.main()

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 defer func() {4 if r := recover(); r != nil {5 fmt.Println("Recovered in f", r)6 fmt.Println("Stack trace of error:")7 debug.PrintStack()8 }9 }()10 fmt.Println("Calling g.")11 g(0)12 fmt.Println("Returned normally from g.")13}14func g(i int) {15 if i > 3 {16 fmt.Println("Panicking!")17 panic(fmt.Sprintf("%v", i))18 }19 defer fmt.Println("Defer in g", i)20 fmt.Println("Printing in g", i)21 g(i + 1)22}23main.main()24import (25func main() {26 defer func() {27 if r := recover(); r != nil {28 fmt.Println("Recovered in f", r)29 fmt.Println("Stack trace of error:")30 debug.PrintStack()31 }32 }()33 fmt.Println("Calling g.")34 g(0)35 fmt.Println("Returned normally from g.")36}37func g(i int) {38 if i > 3 {39 fmt.Println("Panicking!")40 panic(fmt.Sprintf("%v", i))41 }42 defer fmt.Println("Defer in g", i)43 fmt.Println("Printing in g", i)44 g(i + 1)45}

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 defer func() {4 if r := recover(); r != nil {5 fmt.Println("Recovered in f", r)6 fmt.Println("Stack trace of panic: ")7 debug.PrintStack()8 }9 }()10 fmt.Println("Calling g.")11 g(0)12 fmt.Println("Returned normally from g.")13}14func g(i int) {15 if i > 3 {16 fmt.Println("Panicking!")17 panic(fmt.Sprintf("%v", i))18 }19 defer fmt.Println("Defer in g", i)20 fmt.Println("Printing in g", i)21 g(i + 1)22}23func init() {24 fmt.Println("NumCPU: ", runtime.NumCPU())25 fmt.Println("Version: ", runtime.Version())26}27import (28func main() {29 fmt.Println("NumCPU: ", runtime.NumCPU())30 fmt.Println("Version: ", runtime.Version())31}

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println(os.Args[1])5 fmt.Println(os.Args[2])6 fmt.Println(os.Args[3])7 fmt.Println(os.Args[4])8 fmt.Println(os.Args[5])9 fmt.Println(os.Args[6])10 fmt.Println(os.Args[7])11 fmt.Println(os.Args[8])12 fmt.Println(os.Args[9])13 fmt.Println(os.Args[10])14 fmt.Println(os.Args[11])15 fmt.Println(os.Args[12])16 fmt.Println(os.Args[13])17 fmt.Println(os.Args[14])18 fmt.Println(os.Args[15])19 fmt.Println(os.Args[16])20 fmt.Println(os.Args[17])21 fmt.Println(os.Args[18])22 fmt.Println(os.Args[19])23 fmt.Println(os.Args[20])24 fmt.Println(os.Args[21])25 fmt.Println(os.Args[22])26 fmt.Println(os.Args[23])27 fmt.Println(os.Args[24])28 fmt.Println(os.Args[25])29 fmt.Println(os.Args[26])30 fmt.Println(os.Args[27])31 fmt.Println(os.Args[28])32 fmt.Println(os.Args[29])33 fmt.Println(os.Args[30])34 fmt.Println(os.Args[31])35 fmt.Println(os.Args[32])36 fmt.Println(os.Args[33])37 fmt.Println(os.Args[34])38 fmt.Println(os.Args[35])39 fmt.Println(os.Args[36])40 fmt.Println(os.Args[37])41 fmt.Println(os.Args[38])42 fmt.Println(os.Args[39])43 fmt.Println(os.Args[40])44 fmt.Println(os.Args[41])45 fmt.Println(os.Args[42])46 fmt.Println(os.Args[43])47 fmt.Println(os.Args[44])48 fmt.Println(os.Args[45])49 fmt.Println(os.Args[46])50 fmt.Println(os.Args[47])51 fmt.Println(os.Args[48])52 fmt.Println(os.Args[49])53 fmt.Println(os.Args[50])54 fmt.Println(os.Args[51])55 fmt.Println(os.Args[52])56 fmt.Println(os.Args[53])57 fmt.Println(os.Args[54])58 fmt.Println(os.Args[55])59 fmt.Println(os.Args[56])60 fmt.Println(os.Args[57])61 fmt.Println(os.Args[58])62 fmt.Println(os.Args[59])

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(strings.Panicked("Hello"))4}5import (6func main() {7 fmt.Println(strings.Panicked("Hello"))8}9import (10func main() {11 fmt.Println(strings.Panicked("Hello"))12}13import (14func main() {15 fmt.Println(strings.Panicked("Hello"))16}17Recommended Posts: Go | strings.Repeat() method18Go | strings.SplitAfter() method19Go | strings.SplitAfterN() method20Go | strings.SplitN() method21Go | strings.Split() method22Go | strings.TrimLeftFunc() method23Go | strings.TrimPrefix() method24Go | strings.TrimRightFunc() method25Go | strings.TrimRight() method26Go | strings.TrimSpace() method27Go | strings.TrimSpace() method28Go | strings.TrimSuffix() method29Go | strings.Trim() method30Go | strings.Title() method31Go | strings.ToTitle() method32Go | strings.ToTitleSpecial() method33Go | strings.ToValidUTF8() method34Go | strings.ToLower() method35Go | strings.ToLowerSpecial() method36Go | strings.ToUpper() method37Go | strings.ToUpperSpecial() method

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 rand.Seed(time.Now().UTC().UnixNano())4 p = types.Panicked{rand.Intn(100)}5 fmt.Println(p)6 fmt.Println(p.Panicked())7}8import (9func main() {10 rand.Seed(time.Now().UTC().UnixNano())11 p = types.Panicked{rand.Intn(100)}12 fmt.Println(p)13 fmt.Println(p.Panicked())14}15import (16func main() {17 rand.Seed(time.Now().UTC().UnixNano())18 p = types.Panicked{rand.Intn(100)}19 fmt.Println(p)20 fmt.Println(p.Panicked())21}22import (23func main() {24 rand.Seed(time.Now().UTC().UnixNano())25 p = types.Panicked{rand.Intn(100)}26 fmt.Println(p)27 fmt.Println(p.Panicked())28}29import (30func main() {31 rand.Seed(time.Now().UTC().UnixNano())32 p = types.Panicked{rand.Intn(100)}33 fmt.Println(p)34 fmt.Println(p.Panicked())35}36import (37func main() {38 rand.Seed(time.Now().UTC().UnixNano())39 p = types.Panicked{rand.Int

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 slice1 := []int{1, 2, 3, 4, 5}4 slice2 := []string{"a", "b", "c", "d", "e"}5 slice3 := []float32{1.2, 2.3, 3.4, 4.5, 5.6}6 slice4 := []bool{true, false, true, false, true}7 slice5 := []int32{10, 20, 30, 40, 50}8 slice6 := []int64{100, 200, 300, 400, 500}9 array1 := [5]int{1, 2, 3, 4, 5}10 array2 := [5]string{"a", "b", "c", "d", "e"}11 array3 := [5]float32{1.2, 2.3, 3.4, 4.5, 5.6}12 array4 := [5]bool{true, false, true, false, true}13 array5 := [5]int32{10, 20, 30, 40, 50}14 array6 := [5]int64{100, 200, 300

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println("Current OS is ", runtime.GOOS)5 fmt.Println("Current GOARCH is ", runtime.GOARCH)6 fmt.Println("Current NumCPU is ", runtime.NumCPU())7 fmt.Println("Current NumGoroutine is ", runtime.NumGoroutine())8 fmt.Println("Current Version is ", runtime.Version())9 fmt.Println("Current GOOS is ", runtime.GOOS)10 fmt.Println("Current GOARCH is ", runtime.GOARCH)11 fmt.Println("Current NumCPU is ", runtime.NumCPU())12 fmt.Println("Current NumGoroutine is ", runtime.NumGoroutine())13 fmt.Println("Current Version is ", runtime.Version())14}15import (16func main() {17 fmt.Println("Hello, playground")18 fmt.Println("Current OS is ", runtime.GOOS)19 fmt.Println("Current GOARCH is ", runtime.GOARCH)20 fmt.Println("Current NumCPU is ", runtime.NumCPU())21 fmt.Println("Current NumGoroutine is ", runtime.NumGoroutine())22 fmt.Println("Current Version is ", runtime.Version())23 fmt.Println("Current GOOS is ", runtime.GOOS)24 fmt.Println("Current GOARCH is ", runtime.GOARCH)25 fmt.Println("Current NumCPU is ", runtime.NumCPU())26 fmt.Println("Current NumGoroutine is ", runtime.NumGoroutine())27 fmt.Println("Current Version is ", runtime.Version())28}

Full Screen

Full Screen

Panicked

Using AI Code Generation

copy

Full Screen

1func main(){2 fmt.Println(panic.Panicked())3}4func main(){5 panic.Panic("Panic")6 fmt.Println(panic.Recover())7}8func main(){9 panic.Panic("Panic")10 fmt.Println(panic.Recover())11}12func main(){13 panic.Panic("Panic")14 fmt.Println(panic.Recover())15}16func main(){17 panic.Panic("Panic")18 fmt.Println(panic.Recover())19}20func main(){21 panic.Panic("Panic")22 fmt.Println(panic.Recover())23}24func main(){25 panic.Panic("Panic")26 fmt.Println(panic.Recover())27}28func main(){29 panic.Panic("Panic")30 fmt.Println(panic.Recover())31}32func main(){33 panic.Panic("Panic")34 fmt.Println(panic.Recover())35}36func main(){37 panic.Panic("Panic")38 fmt.Println(panic.Recover())39}40func main(){41 panic.Panic("Panic")42 fmt.Println(panic.Recover())43}44func main(){45 panic.Panic("Panic")46 fmt.Println(panic.Recover())47}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Ginkgo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful