Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example of switching p2a to dune #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions p2a/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions p2a/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 1.0)
3 changes: 3 additions & 0 deletions p2a/dune-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 1.0)
(context default)
(profile release)
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions p2a/src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name basics)
(public_name basics))
3 changes: 3 additions & 0 deletions p2a/test/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(test
(name public)
(libraries basics ounit))
File renamed without changes.
File renamed without changes.
37 changes: 0 additions & 37 deletions p4/Makefile

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions p4/dep/sets/META
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description = ""
version = "1.0.0"

archive(byte) = "sets.cma"
archive(native) = "sets.cmxa"
14 changes: 14 additions & 0 deletions p4/dep/sets/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BYTECC = ocamlc
NATIVECC = ocamlopt
CMO_DEPENDS = sets.cmo
PACKS=str

all: sets_pkg

sets_pkg: sets.cma META
ocamlfind install sets META sets.cmi sets.cma

sets.cma: $(CMO_DEPENDS)
ocamlfind $(BYTECC) -a -o $@ -linkpkg -package $(PACKS) -g $(CMO_DEPENDS)

# Need to also include the cmxa for running tests... not sure how to build those yet
Binary file added p4/dep/sets/sets.cma
Binary file not shown.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions p4/dep/sets/sets.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
opam-version: "1.2"
name: "sets"
version: "1.0.0"
build: [
["make"]
]
descr: "test"
1 change: 1 addition & 0 deletions p4/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 1.0)
3 changes: 3 additions & 0 deletions p4/dune-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 1.0)
(context default)
(profile release)
3 changes: 3 additions & 0 deletions p4/src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name regexpi)
(libraries sets))
2 changes: 1 addition & 1 deletion p4/nfa.ml → p4/src/nfa.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ let move m qs s = failwith "unimplemented"

let e_closure m qs = failwith "unimplemented"

let accept m str = failwith "unimplemented"
let accept m str = if elem "x" [ "y" ] then true else false

let nfa_to_dfa m = failwith "unimplemented"
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions p4/test/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(test
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"test" --> "executable" will get rid of the cmxa warning.

(name public)
(libraries regexpi ounit))

(alias
(name runtest)
(action (run ./public.bc)))
4 changes: 2 additions & 2 deletions p4/public.ml → p4/test/public.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open OUnit2
open Nfa
open Regexp
open Regexpi.Nfa
open Regexpi.Regexp
open TestUtils

let test_nfa_accept ctxt =
Expand Down
13 changes: 7 additions & 6 deletions p4/testUtils.ml → p4/test/testUtils.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Nfa
open Regexpi.Nfa
open Regexpi.Regexp
open OUnit2

let assert_true x = assert_equal true x;;
Expand All @@ -17,23 +18,23 @@ let assert_dfa m =

(* Helpers for clearly testing the accept function *)
let assert_nfa_accept nfa input =
if not @@ Nfa.accept nfa input then
if not @@ accept nfa input then
assert_failure @@ Printf.sprintf "NFA should have accept string '%s', but did not" input

let assert_nfa_deny nfa input =
if Nfa.accept nfa input then
if accept nfa input then
assert_failure @@ Printf.sprintf "NFA should not have accepted string '%s', but did" input

let assert_nfa_closure nfa ss es =
let es = List.sort compare es in
let rcv = List.sort compare @@ Nfa.e_closure nfa ss in
let rcv = List.sort compare @@ e_closure nfa ss in
if not (es = rcv) then
assert_failure @@ Printf.sprintf "Closure failure: Expected %s, received %s" (string_of_int_list es) (string_of_int_list rcv)

let assert_nfa_move nfa ss mc es =
let es = List.sort compare es in
let rcv = List.sort compare @@ Nfa.move nfa ss mc in
let rcv = List.sort compare @@ move nfa ss mc in
if not (es = rcv) then
assert_failure @@ Printf.sprintf "Move failure: Expected %s, received %s" (string_of_int_list es) (string_of_int_list rcv)

let assert_regex_string_equiv rxp = assert_equal rxp @@ Regexp.string_to_regexp @@ Regexp.regexp_to_string rxp
let assert_regex_string_equiv rxp = assert_equal rxp @@ string_to_regexp @@ regexp_to_string rxp