diff options
author | dwheeler <dwheeler@d762cc98-fd17-0410-9a0d-d09172385bc5> | 2006-07-07 13:36:27 +0000 |
---|---|---|
committer | dwheeler <dwheeler@d762cc98-fd17-0410-9a0d-d09172385bc5> | 2006-07-07 13:36:27 +0000 |
commit | 05095851346f52c8e918176e8e2abdf0b21de5ec (patch) | |
tree | 8de964f5eea4c7d80faf34d5d744e215a053ba8f /testcode | |
download | sloccount-05095851346f52c8e918176e8e2abdf0b21de5ec.tar.gz |
git-svn-id: svn://svn.code.sf.net/p/sloccount/code/trunk@1 d762cc98-fd17-0410-9a0d-d09172385bc5
Diffstat (limited to 'testcode')
-rw-r--r-- | testcode/conditions.CBL | 31 | ||||
-rw-r--r-- | testcode/hello.f | 10 | ||||
-rw-r--r-- | testcode/hello.f90 | 7 | ||||
-rw-r--r-- | testcode/hello.pas | 9 | ||||
-rw-r--r-- | testcode/hello1.pas | 12 | ||||
-rw-r--r-- | testcode/messages.rb | 152 | ||||
-rw-r--r-- | testcode/temp.c | 5 | ||||
-rw-r--r-- | testcode/test.hs | 19 | ||||
-rw-r--r-- | testcode/test1.inc | 23 | ||||
-rw-r--r-- | testcode/test1.lhs | 15 | ||||
-rw-r--r-- | testcode/test1.php | 27 | ||||
-rw-r--r-- | testcode/test2.lhs | 44 | ||||
-rw-r--r-- | testcode/wokka.cbl | 4 | ||||
-rw-r--r-- | testcode/wokka.cs | 8 |
14 files changed, 366 insertions, 0 deletions
diff --git a/testcode/conditions.CBL b/testcode/conditions.CBL new file mode 100644 index 0000000..8e12724 --- /dev/null +++ b/testcode/conditions.CBL @@ -0,0 +1,31 @@ + $ SET SOURCEFORMAT"FREE"
+IDENTIFICATION DIVISION.
+PROGRAM-ID. Conditions.
+AUTHOR. Michael Coughlan.
+* An example program demonstrating the use of
+* condition names (level 88's).
+* The EVALUATE and PERFORM verbs are also used.
+
+DATA DIVISION.
+WORKING-STORAGE SECTION.
+01 Char PIC X.
+ 88 Vowel VALUE "a", "e", "i", "o", "u".
+ 88 Consonant VALUE "b", "c", "d", "f", "g", "h"
+ "j" THRU "n", "p" THRU "t", "v" THRU "z".
+ 88 Digit VALUE "0" THRU "9".
+ 88 ValidCharacter VALUE "a" THRU "z", "0" THRU "9".
+
+PROCEDURE DIVISION.
+Begin.
+ DISPLAY "Enter lower case character or digit. No data ends.".
+ ACCEPT Char.
+ PERFORM UNTIL NOT ValidCharacter
+ EVALUATE TRUE
+ WHEN Vowel DISPLAY "The letter " Char " is a vowel."
+ WHEN Consonant DISPLAY "The letter " Char " is a consonant."
+ WHEN Digit DISPLAY Char " is a digit."
+ WHEN OTHER DISPLAY "problems found"
+ END-EVALUATE
+ END-PERFORM
+ STOP RUN.
+
diff --git a/testcode/hello.f b/testcode/hello.f new file mode 100644 index 0000000..f66fe77 --- /dev/null +++ b/testcode/hello.f @@ -0,0 +1,10 @@ +c Hello World +* Hello World +! Hello World + program hello + implicit none + print '("Hello, World!")' + end + ! a fancy comment +!hpf$ not a comment +!omp$ not a comment either diff --git a/testcode/hello.f90 b/testcode/hello.f90 new file mode 100644 index 0000000..6b26a2e --- /dev/null +++ b/testcode/hello.f90 @@ -0,0 +1,7 @@ +! Hello World +program hello + implicit none + print '("Hello, World!")' +end program hello +!hpf$ not a comment +!omp$ not a comment either diff --git a/testcode/hello.pas b/testcode/hello.pas new file mode 100644 index 0000000..40c6005 --- /dev/null +++ b/testcode/hello.pas @@ -0,0 +1,9 @@ +{ Hello World in Pascal, for testing SLOCCount. + This is multi-line, testing curly braces. } +(* This is another multi-line comment. + Here's another line. *) +program Hello; +begin (* Main *) + writeln ('Hello, world.') +end. (* Main *) + diff --git a/testcode/hello1.pas b/testcode/hello1.pas new file mode 100644 index 0000000..c53c0d2 --- /dev/null +++ b/testcode/hello1.pas @@ -0,0 +1,12 @@ +{ Hello World in Pascal, for testing SLOCCount. + This is multi-line, testing curly braces. } +(* This is another multi-line comment. + Here's another line. *) +(* This is { another } test. **) +program Hello; +begin (* Main *) + writeln ('Hello, world.'); + writeln ('It''s a test!'); + writeln ('Show that newlines are detected') +end. (* Main *) + diff --git a/testcode/messages.rb b/testcode/messages.rb new file mode 100644 index 0000000..1521ae6 --- /dev/null +++ b/testcode/messages.rb @@ -0,0 +1,152 @@ +#!/usr/local/bin/ruby +# messages.rb - this is a test for the Ruby SLOC counter. +# You should get 110 SLOC for this file. + +# Guru module: private messages among players +# Copyright (C) 2001, 2002 Josef Spillner, dr_maux@user.sourceforge.net +# This is used as a test case in SLOCCount, a toolsuite that counts +# source lines of code (SLOC). +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# To contact David A. Wheeler, see his website at: +# http://www.dwheeler.com. +# +# + +# Commands: +# guru do i have any messages +# guru tell grubby nice to meet myself :) +# guru alert grubby + +databasedir = ENV['HOME'] + "/.ggz/grubby" + +#################################################################################### + +class GuruMessages + def initialize + @msg = Array.new + @alerts = Array.new + end + def add(fromplayer, player, message) + @entry = Array.new + newmessage = (fromplayer + " said: " + message.join(" ")).split(" ") + @entry << player << newmessage + @msg.push(@entry) + print "OK, I make sure he gets the message." + $stdout.flush + sleep 1 + end + def tell(player) + len = @msg.length + a = 0 + for i in 0..len + unless @msg[len-i] == nil + print @msg[len-i][1][0..@msg[len-i][1].length - 1].join(" ") + "\n" if player == @msg[len-i][0] + if player == @msg[len-i][0] + @msg.delete_at(len-i) + a = 1 + end + end + end + if a == 0 + print "Sorry " + player + ", I guess you're not important enough to get any messages." + end + $stdout.flush + sleep 1 + end + def alert(fromplayer, player) + @entry = Array.new << fromplayer << player + @alerts.push(@entry) + print "OK, I alert " + player + " when I see him." + $stdout.flush + sleep 1 + end + def trigger(player) + len = @alerts.length + a = 0 + for i in 0..len + unless @alerts[len-i] == nil + if player == @alerts[len-i][0] + print player + ": ALERT from " + @alerts[len-i][1] + "\n" + @alerts.delete_at(len-i) + a = 1 + end + end + end + if a == 1 + $stdout.flush + sleep 1 + return 1 + end + return 0 + end +end + +input = $stdin.gets.chomp.split(/\ /) + +mode = 0 +if (input[1] == "do") && (input[2] == "i") && (input[3] == "have") && + (input[4] == "any") && (input[5] == "messages") + mode = 1 + player = ARGV[0] +end +if (input[1] == "tell") + mode = 2 + fromplayer = ARGV[0] + player = input[2] + message = input[3..input.length] +end +if(input[1] == "alert") + mode = 3 + fromplayer = ARGV[0] + player = input[2] +end + +m = nil +begin + File.open(databasedir + "/messages") do |f| + m = Marshal.load(f) + end +rescue + m = GuruMessages.new +end + +if mode == 0 + ret = m.trigger ARGV[0] + if ret == 0 + exit + end +end +if mode == 1 + if player != nil + m.tell player + else + print "If you mind telling me who you are?" + $stdout.flush + sleep 1 + end +end +if mode == 2 + m.add fromplayer, player, message +end +if mode == 3 + m.alert fromplayer, player +end + +File.open(databasedir + "/messages", "w+") do |f| + Marshal.dump(m, f) +end + diff --git a/testcode/temp.c b/testcode/temp.c new file mode 100644 index 0000000..d540f08 --- /dev/null +++ b/testcode/temp.c @@ -0,0 +1,5 @@ + + +main() { + int i; +} diff --git a/testcode/test.hs b/testcode/test.hs new file mode 100644 index 0000000..de874df --- /dev/null +++ b/testcode/test.hs @@ -0,0 +1,19 @@ + +-- This literate program prompts the user for a number +-- and prints the factorial of that number: + +{- This is a comment. -} +{- This is a comment, + too -} + +{-# this is a pragma, COUNT IT -} + + main :: IO () + main = do putStr "Enter a number: " + l <- readLine + putStr "n!= " + print (fact (read l)) + fact :: Integer -> Integer + fact 0 = 1 + fact n = n * fact (n-1) + diff --git a/testcode/test1.inc b/testcode/test1.inc new file mode 100644 index 0000000..a56d14e --- /dev/null +++ b/testcode/test1.inc @@ -0,0 +1,23 @@ +<?php + + /** + * Test file for php_count, part of SLOCCount. This is a C-style comment. + * This file is different from .php. + */ + + // This is a C++-style comment. + + # This is a shell-style comment. + + # Here are 9 lines of code: + + function get() + { + $total = 0; + $simplestring = 'hello'; + $simplestring = '\\hello\''; + $funkystring = "hello"; + $funkystring = "$hi\\\""; + return 0; + } +?> diff --git a/testcode/test1.lhs b/testcode/test1.lhs new file mode 100644 index 0000000..3c19a70 --- /dev/null +++ b/testcode/test1.lhs @@ -0,0 +1,15 @@ +\documentstyle{article} + +\begin{document} + +\section{Introduction} + +This is a trivial program that prints the first 20 +factorials. It should have 2 lines of code. + +\begin{code} +main :: IO () +main = print [ (n, product [1..n]) | n <- [1..20]] +\end{code} + +\end{document} diff --git a/testcode/test1.php b/testcode/test1.php new file mode 100644 index 0000000..9fd2510 --- /dev/null +++ b/testcode/test1.php @@ -0,0 +1,27 @@ +<?php + + /** + * Test file for php_count, part of SLOCCount. This is a C-style comment. + */ + + // This is a C++-style comment. + + # This is a shell-style comment. + + # Here are 13 lines of code: + + function get() + { + $total = 0; + $simplestring = 'hello'; + $simplestring = '\\hello\''; + $funkystring = "hello"; + $funkystring = "$hi\\\""; + $heretest <<< wiggle +juggle + wiggle /* This doesn't end the string, so this isn't a C comment. +wiggle; + return 0; + } + +?> diff --git a/testcode/test2.lhs b/testcode/test2.lhs new file mode 100644 index 0000000..6e39905 --- /dev/null +++ b/testcode/test2.lhs @@ -0,0 +1,44 @@ + +This is an extract of a larger literate Haskell file for testing +SLOCCount. It should have 21 lines of code. + +This dumps the tree in dot format, which is very handy for visualizing +the trees. + +> dotTree name t = "digraph " ++ filter dotChars name ++ " { " ++ (dotTree' t 0) ++ " }" + +> dotTree' Empty _ = "" +> dotTree' t i | is_leaf t = "n"++(show i)++" [label=\""++(show $ x_span t)++ +> "\",shape=box]; " +> | otherwise = "n"++(show i)++" [label=\""++(show $ x_span t)++"\"]; " ++ +> "n"++(show i)++" -> n"++(show (2*i+1))++"; "++ +> "n"++(show i)++" -> n"++(show (2*i+2))++"; "++ +> dotTree' (left t) (2*i+1) ++ +> dotTree' (right t) (2*i+2) +> where is_leaf Node { left = Empty, right = Empty } = True +> is_leaf _ = False +> {- this is a comment + +foo bar baz + +> that +> spans literate blocks -} + +> dotChars '.' = False +> dotChars '/' = False +> dotChars _ = True + +These functions fill in the monotonically increasing index values for +the lines in the finite map. They also do appropriate things to combine +the world values. + +> idxList [] n = [] +> idxList (x:xs) n = (x {idx=n}):(idxList xs (n+1)) + +> idxFM' fm (x,k) = addToFM (delFromFM fm k) k (y {idx=toInteger x}) +> where y = case lookupFM fm k of +> Just foo -> foo +> Nothing -> error $ "No such key: " ++ show k + +> idxFM fm = foldl idxFM' fm (zip [1..sizeFM fm] $ keysFM fm) + diff --git a/testcode/wokka.cbl b/testcode/wokka.cbl new file mode 100644 index 0000000..d7ccd0c --- /dev/null +++ b/testcode/wokka.cbl @@ -0,0 +1,4 @@ + * Comment.
+ IDENTIFICATION DIVISION.
+ PROGRAM-ID. Conditions.
+
diff --git a/testcode/wokka.cs b/testcode/wokka.cs new file mode 100644 index 0000000..fa95425 --- /dev/null +++ b/testcode/wokka.cs @@ -0,0 +1,8 @@ + +/* comment: This has 5 physical lines of code. */ + +class Test { + static void Main() { + System.Console.WriteLine("Hello, World (in C#)"); + } +} |