diff --git a/moo/medit-app/data/test-lua/testfileinfo.lua b/moo/medit-app/data/test-lua/testfileinfo.lua new file mode 100644 index 00000000..317fc9b1 --- /dev/null +++ b/moo/medit-app/data/test-lua/testfileinfo.lua @@ -0,0 +1,36 @@ +require("munit") +require("_moo.os") + +editor = moo.Editor.instance() + +filenames = { moo.tempnam(), moo.tempnam(), moo.tempnam() } +encs = { 'UTF-8', 'UTF-16', 'UCS-4' } + +for i = 1,3 do + if i == 1 then + oi1 = moo.OpenInfo.new_path(filenames[i]).dup() + oi2 = moo.OpenInfo.new_path(filenames[i], encs[i]).dup() + si = moo.SaveInfo.new_path(filenames[i], encs[i]).dup() + elseif i == 2 then + oi1 = moo.OpenInfo.new(gtk.GFile.new_for_path(filenames[i])).dup() + oi2 = moo.OpenInfo.new(gtk.GFile.new_for_path(filenames[i]), encs[i]).dup() + si = moo.SaveInfo.new(gtk.GFile.new_for_path(filenames[i]), encs[i]).dup() + else + oi1 = moo.OpenInfo.new_uri(gtk.GFile.new_for_path(filenames[i]).get_uri()).dup() + oi2 = moo.OpenInfo.new_uri(gtk.GFile.new_for_path(filenames[i]).get_uri(), encs[i]).dup() + si = moo.SaveInfo.new_uri(gtk.GFile.new_for_path(filenames[i]).get_uri(), encs[i]).dup() + end + + ri = moo.ReloadInfo.new(encs[i]).dup() + + doc = editor.new_file(oi1) + doc.set_text('blah') + tassert(doc.save()) + tassert(doc.save_as(si)) + tassert(doc.close()) + doc = editor.open_file(oi2) + tassert(doc.get_text() == 'blah') + tassert(doc.reload()) + tassert(doc.reload(ri)) + tassert(doc.close()) +end diff --git a/moo/medit-app/data/test-lua/testlineends.lua b/moo/medit-app/data/test-lua/testlineends.lua index 40b0ed3a..7ee88d2f 100644 --- a/moo/medit-app/data/test-lua/testlineends.lua +++ b/moo/medit-app/data/test-lua/testlineends.lua @@ -112,7 +112,7 @@ function test_mix() doc.close() end --- test_default() --- test_set() --- test_load() +test_default() +test_set() +test_load() test_mix() diff --git a/moo/medit-app/data/test-lua/testprefs.lua b/moo/medit-app/data/test-lua/testprefs.lua new file mode 100644 index 00000000..6d2f646d --- /dev/null +++ b/moo/medit-app/data/test-lua/testprefs.lua @@ -0,0 +1,63 @@ +require('munit') + +root = 'lua/fake/key/root' +count = 0 + +function new_key() + count = count + 1 + return root .. '/key' .. tostring(count) +end + +key = new_key() +moo.prefs_new_key_bool(key) +tassert(moo.prefs_get_bool(key) == false) +moo.prefs_set_bool(key, true) +tassert(moo.prefs_get_bool(key) == true) +moo.prefs_set_bool(key, false) + +key = new_key() +moo.prefs_new_key_bool(key, true) +tassert(moo.prefs_get_bool(key) == true) +moo.prefs_set_bool(key, false) +tassert(moo.prefs_get_bool(key) == false) +moo.prefs_set_bool(key, true) + +key = new_key() +moo.prefs_new_key_int(key) +tassert(moo.prefs_get_int(key) == 0) +moo.prefs_set_int(key, 8) +tassert(moo.prefs_get_int(key) == 8) +moo.prefs_set_int(key, 0) + +key = new_key() +moo.prefs_new_key_int(key, 15) +tassert(moo.prefs_get_int(key) == 15) +moo.prefs_set_int(key, 8) +tassert(moo.prefs_get_int(key) == 8) +moo.prefs_set_int(key, 15) + +key = new_key() +moo.prefs_new_key_string(key) +tassert(moo.prefs_get_string(key) == nil) +moo.prefs_set_string(key, 'blah') +tassert(moo.prefs_get_string(key) == 'blah') +moo.prefs_set_string(key, nil) +tassert(moo.prefs_get_string(key) == nil) + +key = new_key() +moo.prefs_new_key_string(key, 'foo') +tassert(moo.prefs_get_string(key) == 'foo') +moo.prefs_set_string(key, 'blah') +tassert(moo.prefs_get_string(key) == 'blah') +moo.prefs_set_string(key, nil) +tassert(moo.prefs_get_string(key) == nil) +moo.prefs_set_string(key, 'foo') + +key = new_key() +moo.prefs_new_key_string(key) +tassert(moo.prefs_get_filename(key) == nil) +moo.prefs_set_string(key, '/tmp/foo') +tassert(moo.prefs_get_filename(key) == '/tmp/foo') +moo.prefs_set_string(key, 'file:///tmp/foo') +tassert(moo.prefs_get_file(key).get_path() == '/tmp/foo') +moo.prefs_set_string(key, nil) diff --git a/moo/medit-app/data/test-lua/testwindow.lua b/moo/medit-app/data/test-lua/testwindow.lua new file mode 100644 index 00000000..7dde09e9 --- /dev/null +++ b/moo/medit-app/data/test-lua/testwindow.lua @@ -0,0 +1,43 @@ +require("munit") + +window = editor.new_window() +tassert(#window.get_docs() == 1) +tassert(window.get_docs()[1] == window.get_active_doc()) +editor.new_doc(window) +tassert(#window.get_docs() == 2) +tassert(window.get_docs()[2] == window.get_active_doc()) +tassert(window.close_all()) +tassert(#window.get_docs() <= 1) + +doc1 = window.get_active_doc() +if not doc1 then + doc1 = editor.new_doc(window) +end + +doc2 = editor.new_doc(window) +doc3 = editor.new_doc(window) +doc4 = editor.new_doc(window) + +tab1 = doc1.get_tab() +tab2 = doc2.get_tab() +tab3 = doc3.get_tab() +tab4 = doc4.get_tab() + +view1 = doc1.get_view() +view2 = doc2.get_view() +view3 = doc3.get_view() +view4 = doc4.get_view() + +tassert(window.get_n_tabs() == 4) + +window.set_active_tab(tab3) +tassert(window.get_active_tab() == tab3) +tassert(window.get_active_doc() == doc3) +tassert(window.get_active_view() == view3) + +window.set_active_doc(doc2) +tassert(window.get_active_tab() == tab2) +tassert(window.get_active_doc() == doc2) +tassert(window.get_active_view() == view2) + +window.close() diff --git a/moo/mooutils/moopane.c b/moo/mooutils/moopane.c index 314238f6..83cb3ab4 100644 --- a/moo/mooutils/moopane.c +++ b/moo/mooutils/moopane.c @@ -14,7 +14,7 @@ */ /** - * class:MooPane: (parent GtkObject) + * class:MooPane: (parent GtkObject) (moo.lua 0) **/ #ifdef HAVE_CONFIG_H diff --git a/moo/mooutils/moopaned.c b/moo/mooutils/moopaned.c index 676c7472..58bfadeb 100644 --- a/moo/mooutils/moopaned.c +++ b/moo/mooutils/moopaned.c @@ -14,15 +14,15 @@ */ /** - * class:MooPaned: (parent GtkBin) (constructable) + * class:MooPaned: (parent GtkBin) (constructable) (moo.lua 0) **/ /** - * boxed:MooPaneLabel: + * boxed:MooPaneLabel: (moo.lua 0) **/ /** - * boxed:MooPaneParams: + * boxed:MooPaneParams: (moo.lua 0) **/ #ifdef HAVE_CONFIG_H