JE

 view release on metacpan or  search on metacpan

t/12-statements.t  view on Meta::CPAN


// ===================================================
// 12.6.1 do
// ===================================================

/* 33-45 */

is_eval('3;do;while(0)', 3, 'do with one iteration returning nothing')
is_eval('do 3;while(0)', 3, 'do with one iteration returning something')
is_eval('var x=0; do if(x);else 3;while(!x++)', 3,
	'do with two iterations, returning the value of the first')
is_eval('var x=0; do if(x)4;else 3;while(!x++)', 4,
	'do with two iterations, returning the value of the 2nd')
is_eval('3;var x=0; do;while(!x++)', 3,
	'do with two iterations, returning nothing')

x = 0; y=0
do { if(!x) continue; else ++y; ++y; } while(!x++)
is(y, 2, 'do-continue without label')

x = 0  /* might as well test multiple labels at the same time: */
Saanen: Toggenburg: do { continue Saanen; x = 1 } while (0)
is(x, 0, 'do-continue label')

x = 0, y=0,z=0

t/12-statements.t  view on Meta::CPAN

// 12.6.2 while
// ===================================================

/* 46-58 */

is_eval('var x=0;3;while(!x++);', 3,
	'while with one iteration returning nothing')
is_eval('var x=0;while(!x++)3', 3,
	'while with one iteration returning something')
is_eval('var x=-1; while(++x<2)if(x);else 3;', 3,
	'while with two iterations, returning the value of the first')
is_eval('var x=-1; while(++x<2)if(x)4;else 3;', 4,
	'while with two iterations, returning the value of the 2nd')
is_eval('3;var x=-1; while(++x<2);', 3,
	'do with two iterations, returning nothing')

x = -1; y=0
while(++x<2) { if(!x) continue; else ++y; ++y; }
is(y, 2, 'while-continue without label')

x = 0, y=0
Margaret: Elvira: while(!y++) { continue Margaret; x = 1 }
is(x, 0, 'while-continue label')

x = 0, y=0,z=0

t/12-statements.t  view on Meta::CPAN


error=false, x=0
try{for(;!x++;aouhtnb);}catch(eonht){error=true}
is(error,true,'for(x;y;z) calls GetValue on z')

is_eval('var x=0;3;for(;x<1;++x);', 3,
	'for(;;) with one iteration returning nothing')
is_eval('var x=0;for(;x<1;++x)3', 3,
	'for(;;) with one iteration returning something')
is_eval('var x=-1; for(;++x<2;)if(x);else 3;', 3,
	'for(;;) with two iterations, returning the value of the first')
is_eval('var x=-1; for(;++x<2;)if(x)4;else 3;', 4,
	'for(;;) with two iterations, returning the value of the 2nd')
is_eval('3;var x=-1; for(;++x<2;);', 3,
	'do with two iterations, returning nothing')

x = 0; y=0
for(;x<2;x++) { if(!x) continue; else ++y; ++y; }
is(y+' '+x, '2 2', 'for(;;)-continue without label')

x = 0, y=0
mvemjsun: tgcfaoqtcd: for(;!y++;) { continue tgcfaoqtcd; x = 1 }
is(x, 0, 'while-continue label')

x = 0, z=0

t/12-statements.t  view on Meta::CPAN


error=false, x=0
try{for(var x;!x++;aouhtnb);}catch(eonht){error=true}
is(error,true,'for(var x;y;z) calls GetValue on z')

is_eval('3;for(var x=0;x<1;++x);', 3,
	'for(var;;) with one iteration returning nothing')
is_eval('for(var x=0;x<1;++x)3', 3,
	'for(var;;) with one iteration returning something')
is_eval('; for(var x=-1;++x<2;)if(x);else 3;', 3,
	'for(var;;) with two iterations, returning the value of the first')
is_eval('; for(var x=-1;++x<2;)if(x)4;else 3;', 4,
	'for(var;;) with two iterations, returning the value of the 2nd')
is_eval('3;; for(var x=-1;++x<2;);', 3,
	'for(var;;) with two iterations, returning nothing')

for(var x = 0, y=0;x<2;x++) { if(!x) continue; else ++y; ++y; }
is(y+' '+x, '2 2', 'for(var ;;)-continue without label')

ihat: aur: for(var x = 0, y=0;!y++;) { continue ihat; x = 1 }
is(x, 0, 'for(var;;)-continue label')

x = 0, z=0
urot:for(var y=0;y < 2;++y){
	z += 5

t/12-statements.t  view on Meta::CPAN

is(m, 'thingfoo','for-in converts its rhs to an object')
delete Boolean.prototype.thing

var o1 = {thing:'foo'}

is_eval('var x;3;for(x in o1);', 3,
	'for-in with one iteration returning nothing')
is_eval('var x;for(x in o1)3', 3,
	'for-in with one iteration returning something')
is_eval('var x=0,y;for(y in o)if(x++);else 3;', 3,
	'for-in with two iterations, returning the value of the first')
is_eval('var x=0,y; for(y in o)if(x++)4;else 3;', 4,
	'for-in with two iterations, returning the value of the 2nd')
is_eval('3;var x;for(x in o);', 3,
	'for-in with two iterations, returning nothing')

var a = []
for(a[a.length] in o);
is(a.sort(), 'a,c', 'the lhs gets property names assigned')

x = 0; y=0
for(m in o) { if(x++) continue; else ++y; ++y; }
is(y+' '+x, '2 2', 'for-in-continue without label')

x = 0

t/12-statements.t  view on Meta::CPAN

is(m, 'thingfoo','for-var-in converts its rhs to an object')
delete Boolean.prototype.thing

var o1 = {thing:'foo'}

is_eval('3;for(var x in o1);', 3,
	'for-var-in with one iteration returning nothing')
is_eval('for(var x in o1)3', 3,
	'for-var-in with one iteration returning something')
is_eval('var x=0;for(var y in o)if(x++);else 3;', 3,
	'for-var-in with two iterations, returning the value of the first')
is_eval('var x=0; for(var y in o)if(x++)4;else 3;', 4,
	'for-var-in with two iterations, returning the value of the 2nd')
is_eval('3;for(var x in o);', 3,
	'for-var-in with two iterations, returning nothing')

var a = []
for(var x in o) a.push(x);
is(a.sort(), 'a,c', 'the lhs gets property names assigned')

x = 0; y=0
for(var m in o) { if(x++) continue; else ++y; ++y; }
is(y+' '+x, '2 2', 'for-var-in-continue without label')

x = 0



( run in 0.816 second using v1.01-cache-2.11-cpan-71847e10f99 )