testing-debugging/quickref.tex
changeset 489 bc8d01c3c9b3
parent 401 abf092be95ef
equal deleted inserted replaced
488:85f049b5ec08 489:bc8d01c3c9b3
     1 Creating a linear array:\\
     1 Skeleton of a test:\\
     2 {\ex \lstinline|    x = linspace(0, 2*pi, 50)|}
     2 {\ex \lstinline| if __name__ == '__main__':|}
       
     3 {\ex \lstinline|      result = gcd(48, 64) |}  
       
     4 {\ex \lstinline|      if result != 16:     |}
       
     5 {\ex \lstinline|           print ``Test Failed'' |}
       
     6 {\ex \lstinline|      print ``Test Passed''      |}
     3 
     7 
     4 Plotting two variables:\\
       
     5 {\ex \lstinline|    plot(x, sin(x))|}
       
     6 
     8 
     7 Plotting two lists of equal length x, y:\\
     9 \textbf{Testing}
     8 {\ex \lstinline|    plot(x, y)|}
    10 
       
    11 Get results from function or unit of code being tested.Compare it to original output. Test passed if they match else failed.
       
    12 
       
    13 \textbf{Code Style} 
       
    14 Four Space Indentation
       
    15 79 character limit on a line
       
    16 Funtions should be seperated by 
       
    17 blank line
       
    18 Use Docstring
       
    19 White space around operators 
       
    20    
       
    21 Skeleton of try catch:\\
       
    22 {\ex \lstinline|     try:                  |}
       
    23 {\ex \lstinline|      	  num = int(a)     |}
       
    24 {\ex \lstinline|     except:               |}
       
    25 {\ex \lstinline|         print ``Wrong input...'' |}
       
    26 
       
    27 Starting debugger in ipython:\\
       
    28 {\ex \lstinline|     %debug                  |}