Comments (4)
Sorry for the slow reply; I've been really busy.
Oh, that's a cool project! Did fbc end up in that dataset, with just 8 other programs, just because it meets all the criteria? It seems strange though, because fbc (the compiler) is written in FreeBasic, not C, so its inclusion appears invalid. Only the runtime libraries are written in C. FB is exceedingly closely related to C though; it is basically a subset of C++98 with BASIC syntax (optionally QuickBASIC-compatible) and standard library. The bug you are investigating may be in either FB or C code, I don't know.
Also, it's not accurate to describe FB as a "legacy language compiler" since it's its own, new language rather than a QuickBASIC revival project :)
You're going to have to edit file/large_int.bas, by adding this line before the failing CU_ASSERT_DOUBLE_EQUAL
:
if (abs(cdbl(check(i))-cdbl(n)) <= abs(cdbl(check(i) \ 10000000))) then print "failure with " & check(i) & " " & n
This just copies the test that CU_ASSERT_DOUBLE_EQUAL
expands to.
from fbc.
@CharlesDDNoble, yes, interesting project. We consider unit testing an important part of our development, so very cool to see fbc used for input and study in your research.
The test-suite's CU_ASSERT_* macros generate a generic message that is suitable for most cases where we want to know the expression that failed at a specific file/line number. But as you have discovered, since the context of the assertion is dependent on an input file, the full context is not reported.
The older versions of fbc use CUnit for the testing framework. Around December 2017, we re-implemented it as fbcunit
written in freebasic instead of C, and using a simplified API, However, most of the same macro names are still used across both.
CUnit (fbc 1.05.0 and earlier)
fbc's CU_ASSERT_DOUBLE_EQUAL is defined in inc/CUnit/CUnit.bi
#define CU_ASSERT_DOUBLE_EQUAL(actual, expected, granularity) CU_assertImplementation(-(fabs(cdbl(actual) - (expected)) <= fabs(cdbl(granularity))), __LINE__, "CU_ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")", __FILE__, "", CU_FALSE)
I think the most direct way to get more specific results but still in standard format is to define a new assertion macro, for example, CU_ASSERT_DOUBLE_EQUAL_MSG
to include an extra message to report the specific values:
#define CU_ASSERT_DOUBLE_EQUAL_MSG(actual, expected, granularity, msg) CU_assertImplementation(-(fabs(cdbl(actual) - (expected)) <= fabs(cdbl(granularity))), __LINE__, "CU_ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ") " & msg, __FILE__, "", CU_FALSE)
Then use the new macro, for more specific results:
CU_ASSERT_DOUBLE_EQUAL_MSG( check(i), n, check(i) \ 10000000, "check(" & i & ")=" & check(i) & ", n=" & n )
fbcunit (fbc 1.06.0 and later)
This might make a nice addition, or some variation of it, to current fbcunit test-suite API. This framework is located in https://github.com/freebasic/fbc/tree/master/tests/fbcunit
Solution would be similar:
CU_ASSERT_DOUBLE_EQUAL
is one of many #defines that wraps the test-suite's fbcu.CU_ASSERT_
generic assertion function found in tests/fbcunit/inc/fbcunit.bi:
#define CU_ASSERT_DOUBLE_EQUAL( a, e, g ) fbcu.CU_ASSERT_( (abs(cdbl(a)-cdbl(e)) <= abs(cdbl(g))), __FILE__, __LINE__, __FUNCTION__, "CU_ASSERT_DOUBLE_EQUAL(" #a "," #e "," #g ")" )
Where fbcu.CU_ASSERT_ is declared as:
namespace fbcu
declare sub CU_ASSERT_ _
( _
byval value as boolean, _
byval fil as zstring ptr, _
byval lin as long, _
byval fun as zstring ptr, _
byval msg as zstring ptr _
)
end namespace
value := expression that evaluates to true (pass) or false (fail)
fil := filename (of the test source file)
lin := line number (of the test source file)
fun := function name (of the test source file)
msg := custom message
from fbc.
@rversteegen @jayrm Thanks a lot! I really appreciate the quick feedback!
@rversteegen I am not actually a member of the team that published the paper and created the repository, but I believe FBC was included because it has suffient C source code and some defects in the version history include only changes to C source code (Python and PHP are also projects included for this reason). Many Auto Program Repair (APR) systems are made specifically for C and the purpose of the ManyBugs repository is to provide a system to test APR's.
@jayrm Thanks for the info on the the FBC testing framework, this will come in handy when I am looking into the newer versions.
I ultimately used the method suggested by @rversteegen of just printing the information before the actual assert. I added the code mentioned before the assert (changing the '<=' to '>' to report failures). This is what I used:
if (abs(cdbl(check(i))-cdbl(n)) > abs(cdbl(check(i) \ 10000000))) then print "failure with " & check(i) & " (" & i & ") " & n
Thanks again!
from fbc.
I'd forgotten about the fbcunit rewrite, so that was helpful for me too!
from fbc.
Related Issues (20)
- various argument errors attempting to use curses.bi on linux HOT 1
- _FILE_OBJECT bug HOT 5
- The _DISPATCHER_HEADER structure is incorrect HOT 2
- _IRP Statement bugfix HOT 6
- How to modify FB code to use FB built-in functions in driver development? HOT 1
- unit-tests stuck on ascii HOT 8
- FreeBASIC support for Linux on PowerPC and PowerPC64? HOT 4
- libstdc++-related problems in log-tests HOT 10
- Support for SOURCE_DATE_EPOCH HOT 4
- Golang and FreeBasic HOT 1
- File Append Bug HOT 1
- Date Format Bug HOT 2
- Could fbc achieve the same effect as making a share section in dll HOT 1
- cannot find -ldisphelper HOT 2
- build FreeBasic on macOS 13.1 with clang HOT 1
- if statement fail on div0 HOT 6
- MOVE TO DISCUSSIONS: hdpmi32 and cwsdpmi in dosbox HOT 2
- mangled out
- mangled output windows commandline when using wstr and pipe
- Brecht Sanders MinGW-W64 refrence possibly rather excessive in compiled exe with gcc HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fbc.