Skip to content

Commit

Permalink
Fix/patch repr. Tweak ascii test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavion3 committed May 21, 2014
1 parent 21dcff8 commit acde7fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions filbert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2527,8 +2527,11 @@
return r;
},
repr: function (obj) {
if (x.__repr__ !== undefined) return obj.__repr__();
else return '<'+x.__class__.__module__+'.'+x.__class__.__name__+' object>';
if (typeof obj === 'string') return "'" + obj + "'"; // TODO: Patch until typesystem comes up.
if (obj.__repr__ !== undefined) return obj.__repr__();
else if (obj.__class__ !== undefined && obj.__class__.module !== undefined && obj.__class__.__name__) {
return '<'+obj.__class__.__module__+'.'+obj.__class__.__name__+' object>';
} else return obj.toString(); // Raise a please report warning here, we should never reach this piece of code
},
reversed: function (seq) {
var ret = new pythonRuntime.objects.list();
Expand Down
11 changes: 9 additions & 2 deletions test/spec/runtime_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ describe("Runtime library tests", function () {

it("ascii()", function () {
var code = "\
return ascii(\"TEST\123\xd4\u1234\U00010000\")\
return ascii(\"TEST\123\xd4\u1234\U00028b4e\")\
";
expect(util.run(code)).toBe("'TESTS\\xd4\\u1234\\U00010000'");
expect(util.run(code)).toBe("'TESTS\\xd4\\u1234\\U00028b4e'");
});

it("bool(None)", function () {
Expand Down Expand Up @@ -358,6 +358,13 @@ describe("Runtime library tests", function () {
expect(util.run(code)).toEqual('88');
});

it("repr()", function () {
var code = "\
return repr(\"88\")\n\
";
expect(util.run(code)).toEqual("'88'");
});

it("reversed()", function () {
var code = "\
return reversed(['a', 'b'])\n\
Expand Down

0 comments on commit acde7fc

Please sign in to comment.