summaryrefslogtreecommitdiff
path: root/yaksh/documentation/moderator_docs
diff options
context:
space:
mode:
authoradityacp2020-04-07 14:16:20 +0530
committeradityacp2020-04-07 14:16:20 +0530
commit4d56ce652b4b512080854191aae2925658a1c687 (patch)
tree2b9cc30e63525289fbd1927706be442565cdac93 /yaksh/documentation/moderator_docs
parent7886d4f3ce672a80f3284aba17840b64cf6b19a4 (diff)
downloadonline_test-4d56ce652b4b512080854191aae2925658a1c687.tar.gz
online_test-4d56ce652b4b512080854191aae2925658a1c687.tar.bz2
online_test-4d56ce652b4b512080854191aae2925658a1c687.zip
Add R language standard testcase information
Diffstat (limited to 'yaksh/documentation/moderator_docs')
-rw-r--r--yaksh/documentation/moderator_docs/creating_question.rst37
1 files changed, 37 insertions, 0 deletions
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.