diff options
author | Palaparthy Adityachandra | 2020-04-07 14:26:08 +0530 |
---|---|---|
committer | GitHub | 2020-04-07 14:26:08 +0530 |
commit | 12af42a922679a33ce52df24499e165474fbd7d2 (patch) | |
tree | 2b9cc30e63525289fbd1927706be442565cdac93 | |
parent | 7886d4f3ce672a80f3284aba17840b64cf6b19a4 (diff) | |
parent | 4d56ce652b4b512080854191aae2925658a1c687 (diff) | |
download | online_test-12af42a922679a33ce52df24499e165474fbd7d2.tar.gz online_test-12af42a922679a33ce52df24499e165474fbd7d2.tar.bz2 online_test-12af42a922679a33ce52df24499e165474fbd7d2.zip |
Merge pull request #686 from adityacp/add_r_info_docs
Add R language standard testcase information in documentation
-rw-r--r-- | yaksh/documentation/images/r_standard_testcase.jpg | bin | 0 -> 42217 bytes | |||
-rw-r--r-- | yaksh/documentation/moderator_docs/creating_question.rst | 37 |
2 files changed, 37 insertions, 0 deletions
diff --git a/yaksh/documentation/images/r_standard_testcase.jpg b/yaksh/documentation/images/r_standard_testcase.jpg Binary files differnew file mode 100644 index 0000000..db6bf9b --- /dev/null +++ b/yaksh/documentation/images/r_standard_testcase.jpg diff --git a/yaksh/documentation/moderator_docs/creating_question.rst b/yaksh/documentation/moderator_docs/creating_question.rst index 2c52628..ea2d610 100644 --- a/yaksh/documentation/moderator_docs/creating_question.rst +++ b/yaksh/documentation/moderator_docs/creating_question.rst @@ -244,6 +244,43 @@ How to write Test cases c=a+b; endfunction + * **For R** + .. image:: ../images/r_standard_testcase.jpg + :width: 80% + + Consider a Program to print even or odd number. + The code in the Test case Field should be as follows: :: + + source("function.r") + check_empty = function(obj){ + stopifnot(is.null(obj) == FALSE) + } + check = function(input, output){ + stopifnot(input == output) + } + is_correct = function(){ + if (count == 3){ + quit("no", 31) + } + } + check_empty(odd_or_even(3)) + check(odd_or_even(6), "EVEN") + check(odd_or_even(1), "ODD") + check(odd_or_even(10), "EVEN") + check(odd_or_even(777), "ODD") + check(odd_or_even(778), "EVEN") + count = 3 + is_correct() + + Assuming Students answer to be as below: :: + + odd_or_even <- function(n){ + if(n %% 2 == 0){ + return("EVEN") + } + return("ODD") + } + Check **Delete** Field if a test case is to be removed. |