SML uncaught exception "Use failed: Io: openIn failed on..." - sml

I am new with SML/programming/emacs/all the stuff and when I do the first homework from coursera class I have the old story regarding this error:
[opening is_older.sml]
[use failed: Io: openIn failed on "is_older.sml", Win32TextPrimIO:openRd: failed]
uncaught exception Error
raised at: ../compiler/TopLevel/interact/interact.sml:24.14-24.28
I tried all the possible things found on the forums, topics, like: path,checking any misspelled name of sml file, coding-I put several codes, savings, etc. The only thing I did not made was to custom Emacs and I didn't verify if the SML-mode is working properly since 2 days ago Emacs and SML/NJ were installed.
The last code I wrote - but anyway is not important because it doesn't matter which code is, I have the same error - is this:
fun is_older ((x1,y1,z1), (x2,y2,z2)) =
if z1 < z2
then true
else
if x1 = x1 andalso y1 = y2 andalso z1 < z2
then true
else false;

[use failed: Io: openIn failed on "is_older.sml", Win32TextPrimIO:openRd: failed]
This sounds like like it simply didn't find the file. Maybe you misspelled the name, or it's in a different directory?

Related

OS.FileSys.mkDir that does not raise exception when the directory already exists

I am trying to write a function that creates a directory but does not raise an error when the directory already exists. This is the function:
fun ensureDir s =
(OS.FileSys.mkDir s)
handle OS.SysErr (_, SOME Posix.Error.exist) => ()
I based the pattern OS.SysErr (_, SOME Posix.Error.exist) on the fact that OS.FileSys.mkDir fails with the following error message when the directory already exists:
Poly/ML:
Exception- SysErr ("File exists", SOME EEXIST) raised
SML/NJ:
uncaught exception SysErr [SysErr: File exists [exist]]
raised at: <mkdir.c>
However, I get this error when I try to define the function in the Poly/ML shell:
poly: : error: qualified name Posix.Error.exist illegal here
Static Errors
This is the error in SML/NJ:
Error: variable found where constructor is required: Posix.Error.exist
What mistake did I make in the function definition?
(Poly/ML 5.7.1; SML/NJ 110.79; Ubuntu 20.04)
Posix.Error.exist is a val and not a constructor (like SOME) so
you cannot use it as a pattern in a pattern matching construct. Here
is an equivalent code for what you intended to do.
fun ensureDir s =
(OS.FileSys.mkDir s)
handle e as (OS.SysErr (_, SOME err)) =>
if err = Posix.Error.exist
then ()
else raise e
;

Boost data-driven test output: "Assertion occurred in a following context"

I have a question regarding the output of the following minimal example that uses Boost test.
#define BOOST_TEST_MODULE ExampleTestSuite
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
using boost::unit_test::framework::master_test_suite;
#include <boost/test/data/test_case.hpp>
namespace bdata = boost::unit_test::data;
BOOST_DATA_TEST_CASE(ExampleTest, bdata::xrange(2), testDatum) {
int exp = testDatum == 0 ? 0 : 1;
BOOST_CHECK_EQUAL(testDatum, exp);
}
If I run this test with ./boost_testing --log_level=all, I get the following output:
Running 2 test cases...
Entering test module "ExampleTestSuite"
boost_testing.cpp(11): Entering test suite "ExampleTest"
boost_testing.cpp(11): Entering test case "_0"
boost_testing.cpp(15): info: check testDatum == exp has passed
Assertion occurred in a following context:
testDatum = 0;
boost_testing.cpp(11): Leaving test case "_0"
boost_testing.cpp(11): Entering test case "_1"
boost_testing.cpp(15): info: check testDatum == exp has passed
Assertion occurred in a following context:
testDatum = 1;
boost_testing.cpp(11): Leaving test case "_1"
boost_testing.cpp(11): Leaving test suite "ExampleTest"
Leaving test module "ExampleTestSuite"
*** No errors detected
What is the meaning of the output line Assertion occurred in a following context: testDatum = 0;? Does it indicate an issue with the way that I have set up the data-driven test case or can I safely ignore it?
I agree the message is confusing: this is in fact the description of the assertion context for the test BOOST_CHECK_EQUAL(testDatum, exp), and in fact this is not describing an error, but the context attached to the check. If you change --log_level=all to something else, or user another output format, this should go away.
Feel free to raise an issue on Boost.Test project

Mage_Selenium_Driver::doCommand() should be compatible with that of PHPUnit_Extensions_SeleniumTestCase_Driver

I am trying to configure Magento test automation framework on my system.
When I run phpunit in command line, I am getting following error. Same error I am getting while running test in the netbeans.
Strict Standards: Declaration of Mage_Selenium_Driver::doCommand() should
be compatible with that of PHPUnit_Extensions_SeleniumTestCase_Driver::doCommand()
in C:\MTAF\taf\lib\Mage\Selenium\Driver.php on line 38
..
Fatal error: Call to undefined method PHPUnit_Framework_TestSuite::isPublicTestMethod() in C:\MTAF\taf\lib\Mage\Selenium\TestCase.php on line 2502
Can some one please suggest some solution for the same.
I changed the code, this is the change I performed:
--- a/framework/Mage/Selenium/TestCase.php
+++ b/framework/Mage/Selenium/TestCase.php
## -409,7 +409,7 ## class Mage_Selenium_TestCase extends PHPUnit_Extensions_SeleniumTestCase
$testMethods = array();
$class = new ReflectionClass(self::$_testClass);
foreach ($class->getMethods() as $method) {
- if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
+ if ($method->isPublic()) {
$testMethods[] = $method->getName();
}
}
I was getting this error when running phpunit >= 4.0. Downgrading to 3.7.x solved it for me.

repeatedly getting uncaught exception in firebug

my project suddenly was started to throwing exception in firebug,I've not added any new thing,I'm confused,the error:
uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLTextAreaElement.selectionStart]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://codeblogging.net/static/js/plugins.js :: :: line 99" data: no]
Line 0
I've just used django-tinymce in my project,but there was no problem until now,I removed the refrences to tinymce.js and tinymce-setup.js,but no difference!I really don't know what has happend!!
I finally updated firefox to 12 version and updated firebug to a compatible version,too.

Suppressing stack trace when Rails tests error

I'm a Ruby on Rails newbie and writing tests. Some of these generate exceptions; I would like the "rake test" output to give me the exception error message but not the whole backtrace. (I'd like to write tests which exercise unimplemented functionality, which I'll then fill in.)
For example, actual output:
Started
E
Finished in 0.081054 seconds.
1) Error:
test_should_fail(VersioningTest):
ActiveRecord::StatementInvalid: PGError: ERROR: null value in column "client_ip" violates not-null constraint
: INSERT INTO "revisions" ("created_at", "id") VALUES ('2011-02-03 20:14:17', 980190962)
/Users/rpriedhorsky/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `rescue in log'
/Users/rpriedhorsky/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:194:in `log'
/Users/rpriedhorsky/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:496:in `execute'
[... etc. etc. etc. ...]
1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
Desired output:
Started
E
Finished in 0.081054 seconds.
1) Error:
test_should_fail(VersioningTest):
ActiveRecord::StatementInvalid: PGError: ERROR: null value in column "client_ip" violates not-null constraint
1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
I found info (e.g.) on the opposite direction, but not on suppressing stack traces.
Edit:
It would be nice to turn them on and off easily; as pointed out below, sometimes they are useful for tracking down bugs.
You could take a look at "backtrace silencers" - for me (Rails 2.3.8), this is the file config/initializers/backtrace_silencers.rb:
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but
# don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying do debug a
# problem that might steem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
Rails.backtrace_cleaner.add_silencer {|line| line =~ /gems/}
Rails.backtrace_cleaner.add_silencer {|line| line =~ /passenger/}
It looks like you should be able to put a line like
Rails.backtrace_cleaner.add_silencer {|line| true}
In your config/environments/test.rb file, and that would wipe your backtraces clean away (though it might just apply to the logger - I'm not very familiar with the method).
But ask yourself - do you really want to do away with backtraces entirely? They can be pretty useful for tracking down bugs...