1
$\begingroup$

I have a list of problems for my students and I'm trying to use the new v10 feature TestResults like so:

solns = {233168,6857}
answers[1] = Inactivate[Total@Select[Range[3, 999], (Mod[#, 3] == 0 || Mod[#, 5] == 0) &]];
answers[2] = Inactivate[FactorInteger[600851475143][[All, 1]][[-1]]];

TestReport@Table[VerificationTest[Activate@answers[i], solns[[i]]], {i, 2}]

But this won't work:

enter image description here

I need to save the code for each solution for further study and check the timing and correctness for each and finally create a report.

$\endgroup$
  • $\begingroup$ TestReport is HoldFirst, so that is likely causing issues. $\endgroup$ – rcollyer Jun 30 '15 at 15:25
  • $\begingroup$ You are right! so how can I achieve this code freezing and testing with TestReport $\endgroup$ – M.R. Jun 30 '15 at 15:31
  • 1
    $\begingroup$ Unfortunately there isn't a good way to do this right now. In Mathematica 10.3 this will work, but until then you could move your code into a .wlt file (Wolfram Language Test file) and do TestReport["filename.wlt"]. $\endgroup$ – Stefan R Jul 15 '15 at 16:51
  • $\begingroup$ Why will we be forced to change the extensions? $\endgroup$ – M.R. Jul 16 '15 at 15:43
1
$\begingroup$

As a workaround, I would suggest something along the lines of:

In[9]:= solns = {233168, 6857};
answers[1] = 
  Inactivate[
   Total@Select[
 Range[3, 999], (Mod[#, 3] == 0 || Mod[#, 5] == 0) &]];
answers[2] = Inactivate[FactorInteger[600851475143][[All, 1]][[-1]]];
#[{"Outcome", "AbsoluteTimeUsed"}] & /@ 
Table[VerificationTest[Activate@answers[i], solns[[i]]], {i, 2}]

Out[12]= {<|"Outcome" -> "Success", 
  "AbsoluteTimeUsed" -> 
   Quantity[0.001808, "Seconds"]|>, <|"Outcome" -> "Success", 
  "AbsoluteTimeUsed" -> Quantity[0.000111, "Seconds"]|>}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.