2
$\begingroup$

I am implementing the Shunting Yard algorithm and would like to ask for some test cases.

Basically I would like those that have implemented the algorithm to share the cases that made them have to go back and adjust their code.

Would this get closed?

EDIT

Is getting/generating test cases a(n interesting) computer science problem or are you "only lazy" (no offense intended, being lazy is a legitimate strategy)?

Fair question, no offense taken.

One of the reasons I asked about it here first is so that we can set a standard for asking for test cases. It might open a new set of questions for the CS:StackExchange site and get more users in here and more different questions; NP and grammar problems are getting boring.

Some of the test I have are

5-3-1           : is (5-3)-1 and not 5-(3-1) to test left associativity  
2^3^4           : is 2^(3^4) and not (2^3)^4 to test right associativity. 
1               : has no operator to test if that will pass through without error.
-1              : is the simplest test of a prefix unary operator. 
(1)             : is the simplest test with parens and no operators.  
0!              : is the simplest test of a postfix unary operator.
-(3-1)          : the unary - has to be applied as a different operator, 
                  i.e. in postfix notation: 31--.  
(3-1)!          : the expression has to be evaluated before applying the factorial operator.
((4-(3-(2-1)))) : to test the shunting yard.
$\endgroup$
5
  • $\begingroup$ IMHO, just frame it as "where can I get test cases for .." or "how can I generate test cases for ..". $\endgroup$
    – Realz Slaw
    Dec 10, 2013 at 5:27
  • 1
    $\begingroup$ Is getting/generating test cases a(n interesting) computer science problem or are you "only lazy" (no offense intended, being lazy is a legitimate strategy)? $\endgroup$
    – Raphael Mod
    Dec 10, 2013 at 8:03
  • $\begingroup$ @RealzSlaw Generating test cases is limited by my knowledge which is the same knowledge used to write the code. If I have a hole in my reasoning that hole could easily let me make imprecise test cases. As for finding test cases, this is one of the most common algorithms implemented and distributed on the internet. I have yet to find a set of comprehensive test cases and the so called tutorials and blog versions tend not to have the depth I need. The papers are good but again lack sufficient test cases. What I need is test cases with explanations of what they test as I give as examples. $\endgroup$
    – Guy Coder
    Dec 10, 2013 at 11:27
  • $\begingroup$ I agree with Raphael, asking for test cases for some personal code is not useful for others, but you might be able to phrase the question more generally, e.g. you can ask for test sets of graphs that people use for other similar graph algorithms. $\endgroup$
    – Kaveh
    Dec 10, 2013 at 20:54
  • 2
    $\begingroup$ One more thing you should consider is: Why is your question right for CS.StackExchange, rather than StackOverflow? Most questions about code development belong on StackOverflow, not CS.StackExchange. CS.SE is more appropriate for questions about algorithms, conceptual issues, techniques, principles, etc. It sounds like "I want a good test suite" is more SO than CS, whereas "What's an effective strategy for random testing of parsers?" might be a good question for CS. $\endgroup$
    – D.W. Mod
    Dec 11, 2013 at 1:20

1 Answer 1

5
$\begingroup$

As far as I am concerned, the principles of testing are a part of software engineering (here the academic field, not the profession) which is in turn a part of computer science¹. Therefore, questions that asks about principles of testing, e.g.

  • strategies for random testing,
  • automatic generation of meaningful test cases,
  • combinatoric testing,
  • measures of test quality,
  • related methods of (mathematical) statistics,

etc pp are on-topic for this site; the usual guidelines and policies apply on a case-by-case basis.

Your (incomplete) example, however, I would close for the same reasons we have been closing "check-my-proof" questions: there is nothing to gain for anyone but you, and the community is not willing to do your "homework".

A question that addresses how to test parsers of arithmetic expressions in general would be very welcome, though.


  1. This is a controversial statement, but that's what discussions on this site have yielded.
$\endgroup$
4
  • $\begingroup$ That was one of the outcomes I expected; that's why I asked. $\endgroup$
    – Guy Coder
    Dec 10, 2013 at 13:18
  • $\begingroup$ I do think that there is benefit for others because they would see the test cases and then be able to use them to test there code. If I asked for test cases for an algorithm only for use by me then I would agree that it had benefit for only me, but this is a widely used algorithm with many bad examples on the internet. $\endgroup$
    – Guy Coder
    Dec 10, 2013 at 13:25
  • $\begingroup$ Also, it's not "homework". I am building an interpreter for Prolog and need to ensure I am handling all of the expressions correctly before moving on. I am actually using precedence climbing but did shunting yard as a cross check. $\endgroup$
    – Guy Coder
    Dec 10, 2013 at 14:13
  • 1
    $\begingroup$ @GuyCoder Deciding which question is useful to (many) others is not always easy. Test cases for a homebrew implementation of a niche/homebrew algorithm: definitely too localized. How to test a given well-known (abstract) algorithm that is widely used: probably fine, if there are specific problems. If you just you want a list "important algorithm -> test bank", that's not good for SE but for a Wiki or a Github repository for machine readable files (or even a decicated site). (Btw, if you want to ensure correcteness, no amount of testing will help. Prove it, e.g. with Coq or Isabelle/HOL.) $\endgroup$
    – Raphael Mod
    Dec 10, 2013 at 18:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .