From 4d56ce652b4b512080854191aae2925658a1c687 Mon Sep 17 00:00:00 2001
From: adityacp
Date: Tue, 7 Apr 2020 14:16:20 +0530
Subject: Add R language standard testcase information

---
 yaksh/documentation/images/r_standard_testcase.jpg | Bin 0 -> 42217 bytes
 .../moderator_docs/creating_question.rst           |  37 +++++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 yaksh/documentation/images/r_standard_testcase.jpg

(limited to 'yaksh/documentation')

diff --git a/yaksh/documentation/images/r_standard_testcase.jpg b/yaksh/documentation/images/r_standard_testcase.jpg
new file mode 100644
index 0000000..db6bf9b
Binary files /dev/null and b/yaksh/documentation/images/r_standard_testcase.jpg differ
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.
 
-- 
cgit