How to use Debug method of prog Package

Best Syzkaller code snippet using prog.Debug

parser_test.go

Source:parser_test.go Github

copy

Full Screen

...10 "testing"11 "github.com/unidoc/unipdf/v3/common"12)13func init() {14 common.SetLogger(common.NewConsoleLogger(common.LogLevelDebug))15 //common.SetLogger(common.NewConsoleLogger(common.LogLevelTrace))16}17func quickEval(progText string) (PSObject, error) {18 parser := NewPSParser([]byte(progText))19 prog, err := parser.Parse()20 if err != nil {21 return nil, err22 }23 fmt.Printf("%s\n", progText)24 fmt.Printf("-> Program: %s\n", prog.DebugString())25 exec := NewPSExecutor(prog)26 outputs, err := exec.Execute(nil)27 if err != nil {28 return nil, err29 }30 if len(outputs) != 1 {31 return nil, errors.New("stack result has too many values (>1)")32 }33 stack := PSStack(outputs)34 fmt.Printf("=> Result Stack: %s\n", stack.DebugString())35 return outputs[0], nil36}37func quickTest(progText string) (*PSStack, error) {38 parser := NewPSParser([]byte(progText))39 prog, err := parser.Parse()40 if err != nil {41 return nil, err42 }43 fmt.Printf("%s\n", progText)44 fmt.Printf("-> Program: %s\n", prog.DebugString())45 exec := NewPSExecutor(prog)46 outputs, err := exec.Execute(nil)47 if err != nil {48 return nil, err49 }50 stack := PSStack(outputs)51 return &stack, nil52}53func TestAdd1(t *testing.T) {54 progText := "{ 1 1 add }"55 obj, err := quickEval(progText)56 if err != nil {57 t.Errorf("Error: %v", err)58 return59 }60 val, ok := obj.(*PSInteger)61 if !ok {62 t.Errorf("Wrong output type")63 return64 }65 if val.Val != 2 {66 t.Errorf("Wrong result")67 return68 }69}70func TestAdd2(t *testing.T) {71 progText := "{ 1.1 1 add 3 4 add add }"72 obj, err := quickEval(progText)73 if err != nil {74 t.Errorf("Error: %v", err)75 return76 }77 val, ok := obj.(*PSReal)78 if !ok {79 t.Errorf("Wrong output type")80 return81 }82 if math.Abs(val.Val-9.1) > tolerance {83 t.Errorf("Wrong result")84 return85 }86}87//// 8.3 6.6 sub -> 1.7 (real)88// 8 6.3 sub -> 1.7 (real)89// 8 6 sub -> 2 (int)90func TestSub1(t *testing.T) {91 progText := "{ 8.3 6.6 sub }"92 obj, err := quickEval(progText)93 if err != nil {94 t.Errorf("Error: %v", err)95 return96 }97 val, ok := obj.(*PSReal)98 if !ok {99 t.Errorf("Wrong output type")100 return101 }102 if math.Abs(val.Val-1.7) > tolerance {103 t.Errorf("Wrong result")104 return105 }106}107func TestSub2(t *testing.T) {108 progText := "{ 8 6.3 sub }"109 obj, err := quickEval(progText)110 if err != nil {111 t.Errorf("Error: %v", err)112 return113 }114 val, ok := obj.(*PSReal)115 if !ok {116 t.Errorf("Wrong output type")117 return118 }119 if math.Abs(val.Val-1.7) > tolerance {120 t.Errorf("Wrong result")121 return122 }123}124func TestSub3(t *testing.T) {125 progText := "{ 8 6 sub }"126 obj, err := quickEval(progText)127 if err != nil {128 t.Errorf("Error: %v", err)129 return130 }131 val, ok := obj.(*PSInteger)132 if !ok {133 t.Errorf("Wrong output type")134 return135 }136 if val.Val != 2 {137 t.Errorf("Wrong result")138 return139 }140}141// 6 + (3/8) -> 6.375142// 3 8 div 6 add143// 6 3 8 div add144//145// 8 - (7*3) -> -13146// 8 7 3 mul sub147// 7 3 mul 8 exch sub148// Simple test entry with a single expected PSObject output.149type SimpleTestEntry struct {150 progText string151 expected PSObject152}153func TestArithmetics(t *testing.T) {154 testcases := []SimpleTestEntry{155 {progText: "{ 3 8 div 6 add }", expected: MakeReal(6.375)},156 {progText: "{ 6 3 8 div add }", expected: MakeReal(6.375)},157 {progText: "{ 8 7 3 mul sub }", expected: MakeInteger(-13)},158 {progText: "{ 7 3 mul 8 exch sub }", expected: MakeInteger(-13)},159 }160 for _, testcase := range testcases {161 obj, err := quickEval(testcase.progText)162 if err != nil {163 t.Errorf("Error: %v", err)164 return165 }166 // Maybe not the most robust test (comparing the strings), but should do.167 if obj.DebugString() != testcase.expected.DebugString() {168 t.Errorf("Wrong result: %s != %s", obj.DebugString(), testcase.expected.DebugString())169 return170 }171 }172}173// Complex test entry can have a more complex output.174type ComplexTestEntry struct {175 progText string176 expected string177}178func TestStackOperations(t *testing.T) {179 testcases := []ComplexTestEntry{180 {progText: "{ 7 8 9 3 1 roll }", expected: "[ int:9 int:7 int:8 ]"},181 {progText: "{ 7 8 9 3 -1 roll }", expected: "[ int:8 int:9 int:7 ]"},182 {progText: "{ 9 7 8 3 -1 roll }", expected: "[ int:7 int:8 int:9 ]"},183 {progText: "{ 1 1 0.2 7 8 9 3 1 roll }", expected: "[ int:1 int:1 real:0.20000 int:9 int:7 int:8 ]"},184 }185 for _, testcase := range testcases {186 stack, err := quickTest(testcase.progText)187 if err != nil {188 t.Errorf("Error: %v", err)189 return190 }191 // Maybe not the most robust test (comparing the strings), but should do.192 if stack.DebugString() != testcase.expected {193 t.Errorf("Wrong result: '%s' != '%s'", stack.DebugString(), testcase.expected)194 return195 }196 }197}198func TestFunctionOperations(t *testing.T) {199 testcases := []ComplexTestEntry{200 // atan201 {progText: "{ 0 1 atan }", expected: "[ real:0.00000 ]"},202 {progText: "{ 1 0 atan }", expected: "[ real:90.00000 ]"},203 {progText: "{ -100 0 atan }", expected: "[ real:270.00000 ]"},204 {progText: "{ 4 4 atan }", expected: "[ real:45.00000 ]"},205 }206 for _, testcase := range testcases {207 stack, err := quickTest(testcase.progText)208 if err != nil {209 t.Errorf("Error: %v", err)210 return211 }212 // Maybe not the most robust test (comparing the strings), but should do.213 if stack.DebugString() != testcase.expected {214 t.Errorf("Wrong result: '%s' != '%s'", stack.DebugString(), testcase.expected)215 return216 }217 }218}219func TestVariousCases(t *testing.T) {220 testcases := []ComplexTestEntry{221 // dup222 {progText: "{ 99 dup }", expected: "[ int:99 int:99 ]"},223 // ceiling224 {progText: "{ 3.2 ceiling }", expected: "[ real:4.00000 ]"},225 {progText: "{ -4.8 ceiling }", expected: "[ real:-4.00000 ]"},226 {progText: "{ 99 ceiling }", expected: "[ int:99 ]"},227 // floor228 {progText: "{ 3.2 floor }", expected: "[ real:3.00000 ]"},229 {progText: "{ -4.8 floor }", expected: "[ real:-5.00000 ]"},230 {progText: "{ 99 floor }", expected: "[ int:99 ]"},231 // exp232 {progText: "{ 9 0.5 exp }", expected: "[ real:3.00000 ]"},233 {progText: "{ -9 -1 exp }", expected: "[ real:-0.11111 ]"},234 // and235 {progText: "{ true true and }", expected: "[ bool:true ]"},236 {progText: "{ true false and }", expected: "[ bool:false ]"},237 {progText: "{ false true and }", expected: "[ bool:false ]"},238 {progText: "{ false false and }", expected: "[ bool:false ]"},239 {progText: "{ 99 1 and }", expected: "[ int:1 ]"},240 {progText: "{ 52 7 and }", expected: "[ int:4 ]"},241 // bitshift242 {progText: "{ 7 3 bitshift }", expected: "[ int:56 ]"},243 {progText: "{ 142 -3 bitshift }", expected: "[ int:17 ]"},244 // copy245 {progText: "{ 7 3 2 copy }", expected: "[ int:7 int:3 int:7 int:3 ]"},246 {progText: "{ 7 3 0 copy }", expected: "[ int:7 int:3 ]"},247 // cos248 {progText: "{ 0 cos }", expected: "[ real:1.00000 ]"},249 {progText: "{ 90 cos }", expected: "[ real:0.00000 ]"},250 // eq.251 {progText: "{ 4.0 4 eq }", expected: "[ bool:true ]"},252 {progText: "{ 4 4.0 eq }", expected: "[ bool:true ]"},253 {progText: "{ 4.0 4.0 eq }", expected: "[ bool:true ]"},254 {progText: "{ 4 4 eq }", expected: "[ bool:true ]"},255 {progText: "{ -4 4 eq }", expected: "[ bool:false ]"},256 {progText: "{ false false eq }", expected: "[ bool:true ]"},257 {progText: "{ true false eq }", expected: "[ bool:false ]"},258 {progText: "{ true 4 eq }", expected: "[ bool:false ]"},259 // ge260 {progText: "{ 4.2 4 ge }", expected: "[ bool:true ]"},261 {progText: "{ 4 4 ge }", expected: "[ bool:true ]"},262 {progText: "{ 3.9 4 ge }", expected: "[ bool:false ]"},263 // gt264 {progText: "{ 4.2 4 gt }", expected: "[ bool:true ]"},265 {progText: "{ 4 4 gt }", expected: "[ bool:false ]"},266 {progText: "{ 3.9 4 gt }", expected: "[ bool:false ]"},267 // if268 {progText: "{ 4.2 4 gt {5} if }", expected: "[ int:5 ]"},269 {progText: "{ 4.2 4 gt {4.0 4.0 ge {3} if} if}", expected: "[ int:3 ]"},270 {progText: "{ 4.0 4.0 gt {5} if }", expected: "[ ]"},271 // ifelse272 {progText: "{ 4.2 4 gt {5} {4} ifelse }", expected: "[ int:5 ]"},273 {progText: "{ 3 4 gt {5} {4} ifelse }", expected: "[ int:4 ]"},274 // index275 {progText: "{ 0 1 2 3 4 5 2 index }", expected: "[ int:0 int:1 int:2 int:3 int:4 int:5 int:3 ]"},276 {progText: "{ 9 8 7 2 index }", expected: "[ int:9 int:8 int:7 int:9 ]"},277 // le278 {progText: "{ 4.2 4 le }", expected: "[ bool:false ]"},279 {progText: "{ 4 4 le }", expected: "[ bool:true ]"},280 {progText: "{ 3.9 4 le }", expected: "[ bool:true ]"},281 // ln282 {progText: "{ 10 ln }", expected: "[ real:2.30259 ]"},283 {progText: "{ 100 ln }", expected: "[ real:4.60517 ]"},284 // log285 {progText: "{ 10 log }", expected: "[ real:1.00000 ]"},286 {progText: "{ 100 log }", expected: "[ real:2.00000 ]"},287 // lt288 {progText: "{ 4.2 4 lt }", expected: "[ bool:false ]"},289 {progText: "{ 4 4 lt }", expected: "[ bool:false ]"},290 {progText: "{ 3.9 4 lt }", expected: "[ bool:true ]"},291 // ne292 {progText: "{ 4.0 4 ne }", expected: "[ bool:false ]"},293 {progText: "{ 4 4.0 ne }", expected: "[ bool:false ]"},294 {progText: "{ 4.0 4.0 ne }", expected: "[ bool:false ]"},295 {progText: "{ 4 4 ne }", expected: "[ bool:false ]"},296 {progText: "{ -4 4 ne }", expected: "[ bool:true ]"},297 {progText: "{ false false ne }", expected: "[ bool:false ]"},298 {progText: "{ true false ne }", expected: "[ bool:true ]"},299 {progText: "{ true 4 ne }", expected: "[ bool:true ]"},300 // neg301 // not302 {progText: "{ true not }", expected: "[ bool:false ]"},303 {progText: "{ false not }", expected: "[ bool:true ]"},304 {progText: "{ 52 not }", expected: "[ int:-53 ]"},305 // or306 {progText: "{ true true or }", expected: "[ bool:true ]"},307 {progText: "{ true false or }", expected: "[ bool:true ]"},308 {progText: "{ false true or }", expected: "[ bool:true ]"},309 {progText: "{ false false or }", expected: "[ bool:false ]"},310 {progText: "{ 17 5 or }", expected: "[ int:21 ]"},311 // pop312 {progText: "{ 1 2 3 pop }", expected: "[ int:1 int:2 ]"},313 {progText: "{ 1 2 pop }", expected: "[ int:1 ]"},314 {progText: "{ 1 pop }", expected: "[ ]"},315 // round316 {progText: "{ 3.2 round }", expected: "[ real:3.00000 ]"},317 {progText: "{ 6.5 round }", expected: "[ real:7.00000 ]"},318 {progText: "{ -4.8 round }", expected: "[ real:-5.00000 ]"},319 {progText: "{ -6.5 round }", expected: "[ real:-6.00000 ]"},320 {progText: "{ 99 round }", expected: "[ int:99 ]"},321 // roll322 {progText: "{ 1 2 3 3 -1 roll }", expected: "[ int:2 int:3 int:1 ]"},323 {progText: "{ 1 2 3 3 1 roll }", expected: "[ int:3 int:1 int:2 ]"},324 {progText: "{ 1 2 3 3 0 roll }", expected: "[ int:1 int:2 int:3 ]"},325 // sin326 {progText: "{ 0 sin }", expected: "[ real:0.00000 ]"},327 {progText: "{ 90 sin }", expected: "[ real:1.00000 ]"},328 // sqrt329 {progText: "{ 4 sqrt }", expected: "[ real:2.00000 ]"},330 {progText: "{ 2 sqrt }", expected: "[ real:1.41421 ]"},331 // truncate332 {progText: "{ 3.2 truncate }", expected: "[ real:3.00000 ]"},333 {progText: "{ -4.8 truncate }", expected: "[ real:-4.00000 ]"},334 {progText: "{ 99 truncate }", expected: "[ int:99 ]"},335 // xor336 {progText: "{ true true xor }", expected: "[ bool:false ]"},337 {progText: "{ true false xor }", expected: "[ bool:true ]"},338 {progText: "{ false true xor }", expected: "[ bool:true ]"},339 {progText: "{ false false xor }", expected: "[ bool:false ]"},340 {progText: "{ 7 3 xor }", expected: "[ int:4 ]"},341 {progText: "{ 12 3 xor }", expected: "[ int:15 ]"},342 }343 for _, testcase := range testcases {344 stack, err := quickTest(testcase.progText)345 if err != nil {346 t.Errorf("Error: %v", err)347 return348 }349 // Maybe not the most robust test (comparing the strings), but should do.350 if stack.DebugString() != testcase.expected {351 t.Errorf("Wrong result: '%s' != '%s'", stack.DebugString(), testcase.expected)352 return353 }354 }355}356func TestTintTransform1(t *testing.T) {357 testcases := []ComplexTestEntry{358 // from corpus epson_pages3_color_pages1.pdf.359 {progText: "{ 0.0000 dup 0 mul exch dup 0 mul exch dup 0 mul exch 1 mul }", expected: "[ real:0.00000 real:0.00000 real:0.00000 real:0.00000 ]"},360 }361 for _, testcase := range testcases {362 stack, err := quickTest(testcase.progText)363 if err != nil {364 t.Errorf("Error: %v", err)365 return366 }367 // Maybe not the most robust test (comparing the strings), but should do.368 if stack.DebugString() != testcase.expected {369 t.Errorf("Wrong result: '%s' != '%s'", stack.DebugString(), testcase.expected)370 return371 }372 }373}...

Full Screen

Full Screen

base_1203__get_self_md5_sha.go

Source:base_1203__get_self_md5_sha.go Github

copy

Full Screen

1package main2import (3 "bytes"4 "io/ioutil"5 "os"6 //"crypto/md5"7 //"crypto/sha256"8 "encoding/hex"9 "log"10 "time"11 //"strconv"12)13type _Tself struct {14 RoleName string15 //MyId256 _Tb25616 progPath string17 progMd5 _Tb128 // md5sum : 16 byte : 727bf338cf523b90baccd24cca30b91918 progSha _Tb256 // sha256sum : 32 byte : 2c6e3b458d5c482bc52a1d7d4f5a7d7766381c9f07d9b32ca605ae45b4e473f519 startTime time.Time20 startTimEsha _Tb25621 MySeq128 []byte22 debugEnabled bool23} // _Tself24func _Fbase_1203__detect_debug_enabled() {25 // prog : 126 // prog x1 x2 x3 : 427 __VparaLen := len(os.Args)28 if 1 != __VparaLen {29 // func hex.DecodeString(s string) ([]byte, error)30 __Vhex, __Verr := hex.DecodeString(os.Args[__VparaLen-1])31 if nil == __Verr {32 //if fmt.Sprintf("%x" , __Vhex) == fmt.Sprintf("%x" , _VS.progSha ) {33 if bytes.Equal(__Vhex, _VS.progSha.b256) {34 _VS.debugEnabled = true35 }36 }37 }38 log.Printf(" _VS.debugEnabled : %t\n", _VS.debugEnabled)39} // _Fbase_1203__detect_debug_enabled40func _Fbase_1203__gen_self_md5_sha() {41 _VS.progPath = os.Args[0]42 __Vcontent, __Verr := ioutil.ReadFile(_VS.progPath)43 if __Verr != nil {44 log.Fatalf("err138191", __Verr)45 }46 _VS.progSha._Fbase_1101__gen_shaT(&__Vcontent)47 _VS.progMd5._Fbase_1101__gen_md5T(&__Vcontent)48 _FpfN(" 838191 _Fbase_1101b__gen_md5Only return : [%x] (%x %x)", _VS.progMd5.b128, _VS.progMd5.A1, _VS.progMd5.A2)49 _FpfN("from:%s", _VS.progPath)50 _FpfN(" 8381191 File md5: [ %x ]", _VS.progMd5.b128)51 _FpfN(" 8381192 File sha: [ %x ] %x %x %x %x ", _VS.progSha.b256, _VS.progSha.A1, _VS.progSha.A2, _VS.progSha.A3, _VS.progSha.A4)52} // _Fbase_1203__gen_self_md5_sha53func _Fbase_1203__gen_rand_seed() {54 _VS.startTime = time.Now()55 __Vb := []byte(_Spf("%x", _VS.startTime))56 _VS.startTimEsha._Fbase_1101__gen_shaT(&__Vb)57 _VS.MySeq128 = _FgenRand_nByte__(16)58} // _Fbase_1203__gen_rand_seed()59func _Fbase_1203__init_self_All() {60 _Fbase_1203__detect_debug_enabled()61 _Fbase_1203__gen_self_md5_sha()62 _Fbase_1203__gen_rand_seed()63} // _Fbase_1203__init_self_All()...

Full Screen

Full Screen

Debug

Using AI Code Generation

copy

Full Screen

1func main() {2 p := prog{a: 10, b: 20}3 p.Debug()4}5import "fmt"6type prog struct {7}8func (p *prog) Debug() {9 fmt.Println(p.a, p.b)10}11func main() {12 n.Debug()13}14import "fmt"15func (n *int) Debug() {16 fmt.Println(*n)17}18func main() {19 var s []int = []int{1, 2, 3}20 s.Debug()21}22import "fmt"23func (s *[]int) Debug() {24 fmt.Println(*s)25}26func main() {27 var n *int = new(int)28 n.Debug()29}30import "

Full Screen

Full Screen

Debug

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "prog"3func main() {4 fmt.Println("Hello, playground")5 prog.Debug("Hello")6}7import "fmt"8func Debug(s string) {9 fmt.Println(s)10}

Full Screen

Full Screen

Debug

Using AI Code Generation

copy

Full Screen

1import "prog"2func main() {3 prog.Debug("this is a debug message")4}5main.main()6main.main()7flag.(*FlagSet).Var(0xc42006a000, 0x5c1e00, 0xc42000a0e0, 0x57f3d3, 0x5, 0x57f4a4, 0x1e)8flag.(*FlagSet).BoolVar(0xc42006a000, 0xc42000a0e0, 0x57f3d3, 0x5, 0x0, 0x57f4a4, 0x1e)9flag.(*FlagSet).Bool(0xc42006a000, 0x57f3d3, 0x5, 0x0, 0x57f4a4, 0x1e, 0xc42000a0e0)10flag.BoolVar(0xc42000a0e0, 0x57f3d3, 0x5, 0x0,

Full Screen

Full Screen

Debug

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 prog.Debug("Hi! I am in main")4}5import (6func Debug(s string) {7 fmt.Println(s)8}9import (10func Debug(s string) {11 fmt.Println("This is another Debug method")12 fmt.Println(s)13}14import (15func Debug(s string) {16 fmt.Println("This is another Debug method")17 fmt.Println(s)18}19import (20func Debug(s string) {21 fmt.Println("This is another Debug method")22 fmt.Println(s)23}24import (25func Debug(s string) {26 fmt.Println("This is another Debug method")27 fmt.Println(s)28}29import (30func Debug(s string) {31 fmt.Println("This is another Debug method")32 fmt.Println(s)33}34import (35func Debug(s string) {36 fmt.Println("This is another Debug method")37 fmt.Println(s)38}39import (40func Debug(s string) {41 fmt.Println("This is another Debug method")42 fmt.Println(s)43}44import (45func Debug(s string) {46 fmt.Println("This is another Debug method")47 fmt.Println(s)48}49import (50func Debug(s string) {51 fmt.Println("This is another Debug method")52 fmt.Println(s)53}

Full Screen

Full Screen

Debug

Using AI Code Generation

copy

Full Screen

1import "github.com/GoLangPackage/trace"2func main() {3 trace.Debug("This is a debug message")4}5import "github.com/GoLangPackage/trace"6func main() {7 trace.Trace()8}92019/08/08 16:50:33.208 [TRACE] 2.go:8: main.main()10import "github.com/GoLangPackage/trace"11func main() {12 trace.Info("This is an information message")13}14import "github.com/GoLangPackage/trace"15func main() {16 trace.Warn("This is a warning message")17}18import "github.com/GoLangPackage/trace"19func main() {20 trace.Error("This is an error message")21}

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 Syzkaller 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