当前位置: 首页>>代码示例>>Golang>>正文


Golang tardisgolib.CPos函数代码示例

本文整理汇总了Golang中github.com/tardisgo/tardisgo/tardisgolib.CPos函数的典型用法代码示例。如果您正苦于以下问题:Golang CPos函数的具体用法?Golang CPos怎么用?Golang CPos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CPos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: testCallBy

func testCallBy() {
	var a struct {
		b int
	}
	var x [10]int
	var y []int = make([]int, 1)
	var z int
	testCallByValue(a, x, y, z)
	TEQ(tardisgolib.CPos(), a.b, 0)
	TEQ(tardisgolib.CPos(), x[0], 0)
	TEQ(tardisgolib.CPos(), y[0], 44)
	TEQ(tardisgolib.CPos(), z, 0)

	testCallByReference(&a, &x, y, &z)
	TEQ(tardisgolib.CPos(), a.b, 46)
	TEQ(tardisgolib.CPos(), x[0], 47)
	TEQ(tardisgolib.CPos(), y[0], 48)
	TEQ(tardisgolib.CPos(), z, 49)

	var xx [10]float64
	for i := range x {
		xx[i] = float64(i * i)
		testTweakFloatByReference(&xx[i])
		TEQfloat(tardisgolib.CPos(), xx[i], float64(i), 0.1)
	}
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:26,代码来源:test.go

示例2: testMap

func testMap() { // and map-like constucts
	// vowels[ch] is true if ch is a vowel
	vowels := [128]bool{'a': true, 'e': true, 'i': true, 'o': true, 'u': true, 'y': true}
	for k, v := range vowels {
		switch k {
		case 'a', 'e', 'i', 'o', 'u', 'y':
			TEQ(tardisgolib.CPos(), true, v)
		default:
			TEQ(tardisgolib.CPos(), false, v)
		}
	}

	filter := [10]float64{-1, 4: -0.1, -0.1, 9: -1}
	TEQfloat(tardisgolib.CPos(), filter[5], -0.1, 0.01)

	// frequencies in Hz for equal-tempered scale (A4 = 440Hz)
	noteFrequency := map[string]float64{
		"C0": 16.35, "D0": 18.35, "E0": 20.60, "F0": 21.83,
		"G0": 24.50, "A0": 27.50, "B0": 30.87,
	}
	noteFrequency["Test"] = 42.42
	TEQ(tardisgolib.CPos(), len(noteFrequency), 8)
	for k, v := range noteFrequency {
		r := 0.0
		switch k {
		case "C0":
			r = 16.35
		case "D0":
			r = 18.35
		case "E0":
			r = 20.60
		case "F0":
			r = 21.83
		case "G0":
			r = 24.50
		case "A0":
			r = 27.50
		case "B0":
			r = 30.87
		case "Test":
			r = 42.42
		default:
			r = -1
		}
		if !TEQfloat(tardisgolib.CPos()+" Value itterator in map", v, r, 0.01) {
			break
		}
	}
	x, isok := noteFrequency["Test"]
	TEQfloat(tardisgolib.CPos(), 42.42, x, 0.01)
	TEQ(tardisgolib.CPos(), true, isok)
	_, notok := noteFrequency["notHere"]
	TEQ(tardisgolib.CPos(), false, notok)
	delete(noteFrequency, "Test")
	_, isok = noteFrequency["Test"]
	TEQ(tardisgolib.CPos(), false, isok)
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:57,代码来源:test.go

示例3: testClosure

func testClosure() {
	// example from the go tour
	pos, neg := adder(), adder()
	for i := 0; i < 10; i++ {
		pos(i)
		neg(-2 * i)
	}
	TEQ(tardisgolib.CPos(), pos(0), 45)
	TEQ(tardisgolib.CPos(), neg(0), -90)

	// example from http://jordanorelli.tumblr.com/post/42369331748/function-types-in-go-golang
	x := 5
	fn := func(y int) {
		TEQ(tardisgolib.CPos(), x, y)
	}
	fn(5)
	x++
	fn(6)

	f := fib()
	TEQ(tardisgolib.CPos(), f(), 1)
	TEQ(tardisgolib.CPos(), f(), 1)
	TEQ(tardisgolib.CPos(), f(), 2)
	TEQ(tardisgolib.CPos(), f(), 3)
	TEQ(tardisgolib.CPos(), f(), 5)
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:26,代码来源:test.go

示例4: main

func main() {
	//println("Start test running in: " + tardisgolib.Platform())
	testManyGoroutines()
	testChanSelect()
	tourfib()
	testCaseSensitivity()
	testInit()
	testConst()
	testUTF()
	testFloat()
	testMultiRet()
	testAppend()
	testStruct()
	testHeader()
	testCopy()
	testInFuncPtr()
	testCallBy()
	testMap()
	testNamed()
	testFuncPtr()
	testIntOverflow()
	testSlices()
	testChan()
	testComplex()
	testUTF8()
	testString()
	testClosure()
	testVariadic(42)
	testVariadic(40, 2)
	testVariadic(42, -5, 3, 2)
	testInterface()
	testInterfaceMethods()
	testStrconv()
	testTour64()
	testUintDiv32()
	testUintDiv64()
	testDefer()
	aGrWG.Wait()
	TEQint32(tardisgolib.CPos()+" testManyGoroutines() sync/atomic counter:", aGrCtr, 0)
	if tardisgolib.Host() == "haxe" {
		TEQ(tardisgolib.CPos(), int(tardisgolib.HAXE("42;")), int(42))
		TEQ(tardisgolib.CPos(), string(tardisgolib.HAXE("'test';")), "test")
		TEQ(tardisgolib.CPos()+"Num Haxe GR post-wait", tardisgolib.NumGoroutine(), 1)
	} else {
		TEQ(tardisgolib.CPos()+"Num Haxe GR post-wait", tardisgolib.NumGoroutine(), 2)
	}
	//println("End test running in: " + tardisgolib.Platform())
	//println("再见!Previous two chinese characters should say goodbye! (testing unicode output)")
	//println()
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:50,代码来源:test.go

示例5: testFloat

func testFloat() { // and also slices!
	TEQfloat(tardisgolib.CPos(), Sqrt(1024), 32.0, 0.1)
	threeD := make([][][]float64, 10)
	for i := range threeD {
		threeD[i] = make([][]float64, 10)
		for j := range threeD[i] {
			threeD[i][j] = make([]float64, 10)
			for k := range threeD[i][j] {
				threeD[i][j][k] = float64(i) * float64(j) * float64(k)
				TEQfloat(tardisgolib.CPos(), threeD[i][j][k], float64(i)*float64(j)*float64(k), 0.1)
			}
		}
	}
	// TODO add more here
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:15,代码来源:test.go

示例6: testVariadic

func testVariadic(values ...int) {
	total := 0
	for i := range values {
		total += values[i]
	}
	TEQ(tardisgolib.CPos(), total, 42)
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:7,代码来源:test.go

示例7: testFieldFn

func (v Value) testFieldFn() {
	f0 := flag.mv(0, 42)
	f1 := flag.mv
	TEQ(tardisgolib.CPos(), f1(f0, 42), f0)
	rt = new(rtype)
	v.typ = rt
	v.typ.hash = 42
	x := rt.hash
	TEQ(tardisgolib.CPos(), v.typ.hash, x)
	y := &rt.hash
	z := (*y)
	TEQ(tardisgolib.CPos(), z, x)
	var ff interface{} = &v.flag
	*(ff.(*flag)) = 42
	var ffh interface{} = v.typ
	ffh.(*rtype).flag = f1(0, 42)
	TEQ(tardisgolib.CPos(), *(ff.(*flag)), ffh.(*rtype).flag)
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:18,代码来源:test.go

示例8: testTour64

func testTour64() {
	a := []int{7, 2, 8, -9, 4, 0}

	c := make(chan int)
	go sum(a[:len(a)/2], c)
	go sum(a[len(a)/2:], c)
	x, y := <-c, <-c // receive from c

	TEQ(tardisgolib.CPos(), x+y, 12) // x & y could arrive in any order...
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:10,代码来源:test.go

示例9: testString

func testString() {
	TEQ(tardisgolib.CPos(), aString <= "A", true)
	TEQ(tardisgolib.CPos(), aString <= aaString, true)
	TEQ(tardisgolib.CPos(), aString > aaString, false)
	TEQ(tardisgolib.CPos(), aString == aaString, false)
	TEQ(tardisgolib.CPos(), aString+aString == aaString, true)
	TEQ(tardisgolib.CPos(), bbString < aaString, false)
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:8,代码来源:test.go

示例10: testAppend

func testAppend() {
	s0 := []int{0, 0}
	s1 := append(s0, 2) // append a single element     s1 == []int{0, 0, 2}
	TEQintSlice(tardisgolib.CPos(), []int{0, 0, 2}, s1)
	s2 := append(s1, 3, 5, 7) // append multiple elements    s2 == []int{0, 0, 2, 3, 5, 7}
	TEQintSlice(tardisgolib.CPos(), []int{0, 0, 2, 3, 5, 7}, s2)
	s3 := append(s2, s0...) // append a slice              s3 == []int{0, 0, 2, 3, 5, 7, 0, 0}
	TEQintSlice(tardisgolib.CPos(), []int{0, 0, 2, 3, 5, 7, 0, 0}, s3)
	var t []interface{}
	t = append(t, 42, 3.1415, "foo", nil) //       				 t == []interface{}{42, 3.1415, "foo"}
	TEQ(tardisgolib.CPos(), t[0], 42)
	TEQ(tardisgolib.CPos(), t[1], 3.1415)
	TEQ(tardisgolib.CPos(), t[2], "foo")
	TEQ(tardisgolib.CPos(), t[3], nil)

	var b []byte
	b = append(b, "bar"...)
	TEQbyteSlice(tardisgolib.CPos(), b, []byte{'b', 'a', 'r'})
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:19,代码来源:test.go

示例11: testDefer

func testDefer() {
	// examples from http://blog.golang.org/defer-panic-and-recover
	testDefer_a()
	b := make(chan int, 4)
	testDefer_b(b)
	TEQ(tardisgolib.CPos(), <-b, 3)
	TEQ(tardisgolib.CPos(), <-b, 2)
	TEQ(tardisgolib.CPos(), <-b, 1)
	TEQ(tardisgolib.CPos(), <-b, 0)
	TEQ(tardisgolib.CPos(), testDefer_c(), 2)
	protect(g)
	TEQ(tardisgolib.CPos(), tddCount, 6)
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:13,代码来源:test.go

示例12: testStruct

func testStruct() {
	var PrivateStruct struct {
		a int
		b bool
		c string
		d float64
		e interface{}
		f [12]int
		g [6]string
		h [14]struct {
			x bool
			y [3]float64
			z [6]interface{}
		}
	}
	// check that everything is equally initialized
	TEQ(tardisgolib.CPos(), PublicStruct.a, PrivateStruct.a)
	TEQ(tardisgolib.CPos(), PublicStruct.b, PrivateStruct.b)
	TEQ(tardisgolib.CPos(), PublicStruct.c, PrivateStruct.c)
	TEQ(tardisgolib.CPos(), PublicStruct.d, PrivateStruct.d)
	TEQ(tardisgolib.CPos(), PublicStruct.e, PrivateStruct.e)
	TEQintSlice(tardisgolib.CPos(), PublicStruct.f[:], PrivateStruct.f[:])
	PublicStruct.a = 42
	PrivateStruct.a = 42
	TEQ(tardisgolib.CPos(), PublicStruct.a, PrivateStruct.a)
	PublicStruct.c = Name
	PrivateStruct.c = Name
	TEQ(tardisgolib.CPos(), PublicStruct.c, PrivateStruct.c)
	for i := range PrivateStruct.h {
		for j := range PrivateStruct.h[i].y {
			PrivateStruct.h[i].y[j] = 42.0 * float64(i) * float64(j)
			PublicStruct.h[i].y[j] = 42.0 * float64(i) * float64(j)
			TEQfloat(tardisgolib.CPos(), PrivateStruct.h[i].y[j], PublicStruct.h[i].y[j], 1.0)
		}
	}
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:36,代码来源:test.go

示例13: testCopy

func testCopy() {
	var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
	var s = make([]int, 6)
	n1 := copy(s, a[0:]) // n1 == 6, s == []int{0, 1, 2, 3, 4, 5}
	TEQ(tardisgolib.CPos(), n1, 6)
	TEQintSlice(tardisgolib.CPos(), s, []int{0, 1, 2, 3, 4, 5})
	n2 := copy(s, s[2:]) // n2 == 4, s == []int{2, 3, 4, 5, 4, 5}
	TEQ(tardisgolib.CPos(), n2, 4)
	TEQintSlice(tardisgolib.CPos(), s, []int{2, 3, 4, 5, 4, 5})
	var b = make([]byte, 5)
	n3 := copy(b, "Hello, World!") // n3 == 5, b == []byte("Hello")
	TEQ(tardisgolib.CPos(), n3, 5)
	TEQbyteSlice(tardisgolib.CPos(), b, []byte("Hello"))
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:14,代码来源:test.go

示例14: testInterface

func testInterface() {
	var i interface{}

	i = "test"
	if i.(string) != "test" {
		println("testInterface string not equal 'test':")
		println(i)
	}

	i = int(42)
	if i.(int) != 42 {
		println("testInterface int not equal 42:")
		println(i)
	}

	j, ok := i.(rune)
	if ok {
		println("error rune!=int")
	}
	TEQ(tardisgolib.CPos(), j, rune(0))
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:21,代码来源:test.go

示例15: testUTF

func testUTF() {
	var (
		rA, rB, r  []rune
		uS, s1, s2 string
	)
	rA = []rune{0x767d, 0x9d6c, 0x7fd4}
	uS = string(rA) // "\u767d\u9d6c\u7fd4" == "白鵬翔"
	rB = []rune(uS)
	TEQruneSlice(tardisgolib.CPos(), rA, rB)

	s1 = "香港发生工厂班车砍人案12人受伤"
	r = []rune(s1)
	s2 = string(r)
	TEQ(tardisgolib.CPos(), s1, s2)

	TEQ(tardisgolib.CPos(), len(s1), 44)
	TEQ(tardisgolib.CPos(), len(testUTFlength), 9)

	hellø := "hellø"
	TEQ(tardisgolib.CPos(), string([]byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}), hellø)
	TEQbyteSlice(tardisgolib.CPos(), []byte("hellø"), []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'})

	TEQ(tardisgolib.CPos(), "ø", hellø[4:])
}
开发者ID:pombredanne,项目名称:tardisgo,代码行数:24,代码来源:test.go


注:本文中的github.com/tardisgo/tardisgo/tardisgolib.CPos函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。