summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <quaker66@gmail.com>2014-02-18 16:02:30 +0000
committerDaniel Kolesa <quaker66@gmail.com>2014-02-18 16:02:30 +0000
commitf54c86669e06aaf26359204d9985d9af4e43fb9e (patch)
tree9fbec7a8836f12988d6ba2c7b96fa27d77f3fd7f
parenta231ce24edf20f6b3f583465fb25f68eb620cfcc (diff)
get rid of some :format
-rw-r--r--require.lua2
-rw-r--r--tests/proxy_text_random.lua16
-rw-r--r--tests/text.lua16
-rw-r--r--tests/text_change.lua22
4 files changed, 41 insertions, 15 deletions
diff --git a/require.lua b/require.lua
index 7524330..3e3f460 100644
--- a/require.lua
+++ b/require.lua
@@ -35,7 +35,7 @@ local loader = function(modname)
35end 35end
36 36
37local find_loader = function(modname) 37local find_loader = function(modname)
38 local err = ("module '%s' not found\n"):format(modname) 38 local err = "module '" .. modname .. "' not found\n"
39 local v = loader(modname) 39 local v = loader(modname)
40 if type(v) == "function" then 40 if type(v) == "function" then
41 return v 41 return v
diff --git a/tests/proxy_text_random.lua b/tests/proxy_text_random.lua
index a85625b..d1782a3 100644
--- a/tests/proxy_text_random.lua
+++ b/tests/proxy_text_random.lua
@@ -1,5 +1,6 @@
1local ffi = require("ffi") 1local ffi = require("ffi")
2local ffi_new = ffi.new 2local ffi_new = ffi.new
3local C = ffi.C
3local util = require("util") 4local util = require("util")
4local levas = util.get_lib("evas") 5local levas = util.get_lib("evas")
5 6
@@ -11,6 +12,10 @@ local strs = {
11 "Family", "Lair", "Monkeys", "Magazine" 12 "Family", "Lair", "Monkeys", "Magazine"
12} 13}
13 14
15ffi.cdef [[
16 int sprintf(char *str, const char *fmt, ...);
17]]
18
14return function(ui) 19return function(ui)
15 return "text.png", "Proxy Text Random", 5.000, function() 20 return "text.png", "Proxy Text Random", 5.000, function()
16 local itern = 128 21 local itern = 128
@@ -18,13 +23,15 @@ return function(ui)
18 local o_texts = {} 23 local o_texts = {}
19 local win_w, win_h = ui.win_w, ui.win_h 24 local win_w, win_h = ui.win_w, ui.win_h
20 local w, h = ffi_new("Evas_Coord[1]"), ffi_new("Evas_Coord[1]") 25 local w, h = ffi_new("Evas_Coord[1]"), ffi_new("Evas_Coord[1]")
26 local buf = ffi_new("char[48]")
21 ui.func_set(util.del_objs(o_texts), function(t, f) 27 ui.func_set(util.del_objs(o_texts), function(t, f)
22 local o = o_texts[1] 28 local o = o_texts[1]
23 levas.evas_object_text_text_set(o, ("%s %s %s %s."):format( 29 C.sprintf(buf, "%s %s %s %s.",
24 strs[(util.random() % #strs) + 1], 30 strs[(util.random() % #strs) + 1],
25 strs[(util.random() % #strs) + 1], 31 strs[(util.random() % #strs) + 1],
26 strs[(util.random() % #strs) + 1], 32 strs[(util.random() % #strs) + 1],
27 strs[(util.random() % #strs) + 1])) 33 strs[(util.random() % #strs) + 1])
34 levas.evas_object_text_text_set(o, buf)
28 levas.evas_object_geometry_get(o, nil, nil, w, h) 35 levas.evas_object_geometry_get(o, nil, nil, w, h)
29 local w, h = w[0], h[0] 36 local w, h = w[0], h[0]
30 for i = 2, itern do 37 for i = 2, itern do
@@ -38,11 +45,12 @@ return function(ui)
38 local o = levas.evas_object_text_add(evas) 45 local o = levas.evas_object_text_add(evas)
39 o_texts[1] = o 46 o_texts[1] = o
40 levas.evas_object_text_font_set(o, "Vera-Bold", 20) 47 levas.evas_object_text_font_set(o, "Vera-Bold", 20)
41 levas.evas_object_text_text_set(o, ("%s %s %s %s."):format( 48 C.sprintf(buf, "%s %s %s %s.",
42 strs[(util.random() % #strs) + 1], 49 strs[(util.random() % #strs) + 1],
43 strs[(util.random() % #strs) + 1], 50 strs[(util.random() % #strs) + 1],
44 strs[(util.random() % #strs) + 1], 51 strs[(util.random() % #strs) + 1],
45 strs[(util.random() % #strs) + 1])) 52 strs[(util.random() % #strs) + 1])
53 levas.evas_object_text_text_set(o, buf)
46 levas.evas_object_color_set(o, 0, 0, 0, 255) 54 levas.evas_object_color_set(o, 0, 0, 0, 255)
47 levas.evas_object_geometry_get(o, nil, nil, w, h) 55 levas.evas_object_geometry_get(o, nil, nil, w, h)
48 local x = (win_w / 2) - (w[0] / 2) 56 local x = (win_w / 2) - (w[0] / 2)
diff --git a/tests/text.lua b/tests/text.lua
index a0a3545..7a1e1aa 100644
--- a/tests/text.lua
+++ b/tests/text.lua
@@ -1,5 +1,6 @@
1local ffi = require("ffi") 1local ffi = require("ffi")
2local ffi_new = ffi.new 2local ffi_new = ffi.new
3local C = ffi.C
3local util = require("util") 4local util = require("util")
4local levas = util.get_lib("evas") 5local levas = util.get_lib("evas")
5 6
@@ -21,6 +22,10 @@ local weights = {
21 82.0735 22 82.0735
22} 23}
23 24
25ffi.cdef [[
26 int sprintf(char *str, const char *fmt, ...);
27]]
28
24return function(ui, variant) 29return function(ui, variant)
25 return "text.png", variants[variant], weights[variant], function() 30 return "text.png", variants[variant], weights[variant], function()
26 local itern = 128 31 local itern = 128
@@ -41,17 +46,22 @@ return function(ui, variant)
41 end) 46 end)
42 local evas = ui.evas 47 local evas = ui.evas
43 local st = levas.EVAS_TEXT_STYLE_SHADOW 48 local st = levas.EVAS_TEXT_STYLE_SHADOW
44 if variant == 3 then util.randomseed() end 49 local buf
50 if variant == 3 then
51 util.randomseed()
52 buf = ffi_new("char[48]")
53 end
45 for i = 1, itern do 54 for i = 1, itern do
46 local o = levas.evas_object_text_add(evas) 55 local o = levas.evas_object_text_add(evas)
47 o_texts[i] = o 56 o_texts[i] = o
48 levas.evas_object_text_font_set(o, "Vera-Bold", 20) 57 levas.evas_object_text_font_set(o, "Vera-Bold", 20)
49 if variant == 3 then 58 if variant == 3 then
50 levas.evas_object_text_text_set(o, ("%s %s %s %s."):format( 59 C.sprintf(buf, "%s %s %s %s.",
51 strs[(util.random() % #strs) + 1], 60 strs[(util.random() % #strs) + 1],
52 strs[(util.random() % #strs) + 1], 61 strs[(util.random() % #strs) + 1],
53 strs[(util.random() % #strs) + 1], 62 strs[(util.random() % #strs) + 1],
54 strs[(util.random() % #strs) + 1])) 63 strs[(util.random() % #strs) + 1])
64 levas.evas_object_text_text_set(o, buf)
55 else 65 else
56 levas.evas_object_text_text_set(o, "This is a test string") 66 levas.evas_object_text_text_set(o, "This is a test string")
57 end 67 end
diff --git a/tests/text_change.lua b/tests/text_change.lua
index 94c2850..531a831 100644
--- a/tests/text_change.lua
+++ b/tests/text_change.lua
@@ -1,5 +1,6 @@
1local ffi = require("ffi") 1local ffi = require("ffi")
2local ffi_new = ffi.new 2local ffi_new = ffi.new
3local C = ffi.C
3local util = require("util") 4local util = require("util")
4local levas = util.get_lib("evas") 5local levas = util.get_lib("evas")
5 6
@@ -11,6 +12,10 @@ local strs = {
11 12
12local sin, cos = util.sin, util.cos 13local sin, cos = util.sin, util.cos
13 14
15ffi.cdef [[
16 int sprintf(char *str, const char *fmt, ...);
17]]
18
14return function(ui) 19return function(ui)
15 return "text.png", "Text Change", 18.6459, function() 20 return "text.png", "Text Change", 18.6459, function()
16 local itern = 128 21 local itern = 128
@@ -18,13 +23,15 @@ return function(ui)
18 local o_texts = {} 23 local o_texts = {}
19 local win_w, win_h = ui.win_w, ui.win_h 24 local win_w, win_h = ui.win_w, ui.win_h
20 local w, h = ffi_new("Evas_Coord[1]"), ffi_new("Evas_Coord[1]") 25 local w, h = ffi_new("Evas_Coord[1]"), ffi_new("Evas_Coord[1]")
26 local buf = ffi_new("char[48]")
21 ui.func_set(util.del_objs(o_texts), function(t, f) 27 ui.func_set(util.del_objs(o_texts), function(t, f)
22 for i = 1, itern do 28 for i = 1, itern do
23 levas.evas_object_text_text_set(o_texts[i], ("%s %s %s %s.") 29 C.sprintf(buf, "%s %s %s %s.",
24 :format(strs[(util.random() % #strs) + 1], 30 strs[(util.random() % #strs) + 1],
25 strs[(util.random() % #strs) + 1], 31 strs[(util.random() % #strs) + 1],
26 strs[(util.random() % #strs) + 1], 32 strs[(util.random() % #strs) + 1],
27 strs[(util.random() % #strs) + 1])) 33 strs[(util.random() % #strs) + 1])
34 levas.evas_object_text_text_set(o_texts[i], buf)
28 end 35 end
29 end) 36 end)
30 local evas = ui.evas 37 local evas = ui.evas
@@ -33,11 +40,12 @@ return function(ui)
33 local o = levas.evas_object_text_add(evas) 40 local o = levas.evas_object_text_add(evas)
34 o_texts[i] = o 41 o_texts[i] = o
35 levas.evas_object_text_font_set(o, "Vera-Bold", 20) 42 levas.evas_object_text_font_set(o, "Vera-Bold", 20)
36 levas.evas_object_text_text_set(o, ("%s %s %s %s."):format( 43 C.sprintf(buf, "%s %s %s %s.",
37 strs[(util.random() % #strs) + 1], 44 strs[(util.random() % #strs) + 1],
38 strs[(util.random() % #strs) + 1], 45 strs[(util.random() % #strs) + 1],
39 strs[(util.random() % #strs) + 1], 46 strs[(util.random() % #strs) + 1],
40 strs[(util.random() % #strs) + 1])) 47 strs[(util.random() % #strs) + 1])
48 levas.evas_object_text_text_set(o, buf)
41 levas.evas_object_color_set(o, 0, 0, 0, 255) 49 levas.evas_object_color_set(o, 0, 0, 0, 255)
42 levas.evas_object_geometry_get(o, nil, nil, w, h) 50 levas.evas_object_geometry_get(o, nil, nil, w, h)
43 local x = (win_w / 2) - (w[0] / 2) 51 local x = (win_w / 2) - (w[0] / 2)