我想知道是否可以通过scala宏解决以下问题。
我有以下课程和方法。
class Main{
def test(s: String) : String = {
1.initialize some variables.
2.do some operations.
3.as a result some values of variables are changed.
4.do further operations.
5. return some string
}
test("some string")
}
我想
您可以将方法测试划分为两个单独的方法,并对进行划分的变量进行快照。
示例输入代码:
foo(){
int i = 0;
for (int k = 0; k < 100; k++){
i=i+k;
}
for (int k = 0; k < 20; k++){
i=i*k;
}
}
main() {
foo();
}
Output code:
foo1(){
int i = 0;
for (int k = 0; k < 100; k++){
i=i+k;
}
}
foo2(Any[] vars){
initialize variables with 'vars' needed for the code below
for (int k = 0; k < 20; k++){
i=i*k;
}
}
main() {
Any[]vars = foo1();
foo2(vars);
}