123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- while_becomes_for: {
- options = { loops: true };
- input: {
- while (foo()) bar();
- }
- expect: {
- for (; foo(); ) bar();
- }
- }
- drop_if_break_1: {
- options = { loops: true };
- input: {
- for (;;)
- if (foo()) break;
- }
- expect: {
- for (; !foo(););
- }
- }
- drop_if_break_2: {
- options = { loops: true };
- input: {
- for (;bar();)
- if (foo()) break;
- }
- expect: {
- for (; bar() && !foo(););
- }
- }
- drop_if_break_3: {
- options = { loops: true };
- input: {
- for (;bar();) {
- if (foo()) break;
- stuff1();
- stuff2();
- }
- }
- expect: {
- for (; bar() && !foo();) {
- stuff1();
- stuff2();
- }
- }
- }
- drop_if_break_4: {
- options = { loops: true, sequences: true };
- input: {
- for (;bar();) {
- x();
- y();
- if (foo()) break;
- z();
- k();
- }
- }
- expect: {
- for (; bar() && (x(), y(), !foo());) z(), k();
- }
- }
- drop_if_else_break_1: {
- options = { loops: true };
- input: {
- for (;;) if (foo()) bar(); else break;
- }
- expect: {
- for (; foo(); ) bar();
- }
- }
- drop_if_else_break_2: {
- options = { loops: true };
- input: {
- for (;bar();) {
- if (foo()) baz();
- else break;
- }
- }
- expect: {
- for (; bar() && foo();) baz();
- }
- }
- drop_if_else_break_3: {
- options = { loops: true };
- input: {
- for (;bar();) {
- if (foo()) baz();
- else break;
- stuff1();
- stuff2();
- }
- }
- expect: {
- for (; bar() && foo();) {
- baz();
- stuff1();
- stuff2();
- }
- }
- }
- drop_if_else_break_4: {
- options = { loops: true, sequences: true };
- input: {
- for (;bar();) {
- x();
- y();
- if (foo()) baz();
- else break;
- z();
- k();
- }
- }
- expect: {
- for (; bar() && (x(), y(), foo());) baz(), z(), k();
- }
- }
|