Permalink
Browse files

update test with working git_repository_open() calls

  • Loading branch information...
1 parent 1e7760d commit aa5d936018938c20c22a946af93088648ef361e6 @plobsing plobsing committed Jul 12, 2011
Showing with 40 additions and 7 deletions.
  1. +40 −7 t/001_load.pir
View
@@ -1,12 +1,14 @@
#/usr/bin/env parrot
-.sub 'main' :main :load :init
+.include 'datatypes.pasm'
+
+.sub 'main' :main
.include 'test_more.pir'
- plan(3)
+ plan(7)
load_bytecode "./src/git2.pbc"
.local pmc lib
- loadlib lib, '/usr/local/lib/libgit2.so'
+ loadlib lib, '/usr/lib/libgit2.so'
isa_ok(lib, 'ParrotLibrary')
ok(1,"Loaded git2.pbc")
@@ -16,10 +18,41 @@
.sub test_git_repo_open
.param pmc lib
.local pmc nci, repo
- repo = new ['UnManagedStruct']
- dlfunc nci, lib, 'git_repository_open', 'ips'
+
+ $P0 = get_hll_global ['Git2'], 'git_repository'
+
+ $I0 = .DATATYPE_PTR | .DATATYPE_REF_FLAG
+ set $P0, [.DATATYPE_INT; $I0; .DATATYPE_PTR]
+ dlfunc nci, lib, 'git_repository_open', $P0
isa_ok(nci, 'NCI')
- $P1 = nci(repo, "foo.git")
- isa_ok($P1, 'Integer')
+
+ $P0 = str_to_cstring("notarepo.git")
+ ($I1, repo) = nci(repo, $P0)
+ free_cstring($P0)
+ isnt($I1, 0, "non-existant repo reports error")
+ $I1 = isnull repo
+ ok($I1, "invalid repo object populated")
+
+ $P0 = str_to_cstring("./.git")
+ ($I1, repo) = nci(repo, $P0)
+ free_cstring($P0)
+ is($I1, 0, "this repo loaded")
+ $I1 = isnull repo
+ nok($I1, "repo object populated")
+.end
+
+.sub str_to_cstring
+ .param string s
+ $P0 = null
+ $P0 = dlfunc $P0, "Parrot_str_to_cstring", "ppS"
+ $P1 = getinterp
+ $P1 = $P0($P1, s)
+ .return ($P1)
.end
+.sub free_cstring
+ .param pmc cstr
+ $P0 = null
+ $P0 = dlfunc $P0, "Parrot_str_free_cstring", "vp"
+ $P0(cstr)
+.end

0 comments on commit aa5d936

Please sign in to comment.