pike.git/
src/
testsuite.in
Branch:
Tag:
Non-build tags
All tags
No tags
2022-06-28
2022-06-28 14:10:51 by Henrik Grubbström (Grubba) <grubba@grubba.org>
cde55ef1d0d5a2d76d2bad921096e2c76dbbc6e4 (
42
lines) (+
22
/-
20
)
[
Show
|
Annotate
]
Branch:
master
Testsuite
[sprintf]
: Robuster test of derived types.
Use equal() to compare types.
844:
[[ (0xffffffff == -1)?-1:0x7fff ]]); dnl Check the derived return type of sprintf().
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("%1H", "foo"))
)
; ]],
-
"
string(8bit)");
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("foo"))
)
; ]],
-
"
string(102..111)");
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("foo%c", 17))
)
; ]],
-
"
string(17 | 102..111)");
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("%2c\n", 'a'))
)
; ]],
-
"
string(8bit)");
+
test_
equal
([[ typeof(sprintf("%1H", "foo")); ]],
+
[[ typeof([
string(8bit)
](mixed)
"
"
);
]]);
+
test_
equal
([[ typeof(sprintf("foo")); ]],
+
[[ typeof([
string(102..111)
](mixed)
"
"
);
]]);
+
test_
equal
([[ typeof(sprintf("foo%c", 17)); ]],
+
[[ typeof([
string(17 | 102..111)
](mixed)
"
"
);
]]);
+
test_
equal
([[ typeof(sprintf("%2c\n", 'a')); ]],
+
[[ typeof([
string(8bit)
](mixed)
"
"
);
]]);
dnl Note the following tests the return type of int2char().
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("%c", 1023))
)
; ]],
-
"
string(1023)");
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("%c\n", 1023))
)
; ]],
-
"
string(10 | 1023)");
+
test_
equal
([[ typeof(sprintf("%c", 1023)); ]],
+
[[ typeof([
string(1023)
](mixed)
"
"
);
]]);
+
test_
equal
([[ typeof(sprintf("%c\n", 1023)); ]],
+
[[ typeof([
string(10 | 1023)
](mixed)
"
"
);
]]);
dnl The following is due to (string & sprintf_result) == sprintf_result.
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("%c\n", Stdio))
)
; ]],
-
sprintf("%O",
sprintf_result)
)
;
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("%4[1]c", 17))
)
; ]],
-
"
string(8bit)");
-
test_
any
([[
return
sprintf("%O",
typeof(sprintf("%[1]n", 17))
)
; ]],
-
"
string(zero)");
+
test_
equal
([[ typeof(sprintf("%c\n", Stdio)); ]],
+
[[
sprintf_result
; ]]
);
+
test_
equal
([[ typeof(sprintf("%4[1]c", 17)); ]],
+
[[ typeof([
string(8bit)
](mixed)
"
"
)
]])
;
+
test_
equal
([[ typeof(sprintf("%[1]n", 17)); ]],
+
[[ typeof([
string(zero)
](mixed)
"
"
)
]])
;
-
test_
any
([[
return
sprintf("%O",
typeof(aggregate("foo"))
)
;]],
"
array(string(3: 102..111))
"
);
+
test_
equal
([[ typeof(aggregate("foo"));]],
+
[[ typeof([
array(string(3: 102..111))
](mixed
)
({})) ]])
;
test_any([[int a; return sprintf("%O", typeof(aggregate(a)));]], "array(int)"); test_any([[int|string a; string s = sprintf("%O", typeof(aggregate(a)));