JSpec Google Group पर एक संदेश प्राप्त करने के मेरे दो प्रयासों के साथ स्पष्ट रूप से विफल होने के बाद, मैं इसके बजाय यहां पोस्ट कर रहा हूं।जेएसपीसी - रेंज एरर: अधिकतम कॉल स्टैक आकार
मुझे JSpec के साथ एक निश्चित प्रकार के परीक्षण (नीचे) के साथ एक अनंत रिकर्सिव लूप में जाने में परेशानी हो रही है। कोई विचार? क्या मेरे कोड में कुछ गड़बड़ है या यह जेएसपीसी है? मैं रूबी जेम के माध्यम से जेएसपीसी 2.11.2 चला रहा हूँ।
त्रुटियां हैं 'रेंज एरर: अधिकतम कॉल स्टैक आकार पार हो गया।' (सफारी) और 'आंतरिक त्रुटि: बहुत अधिक रिकर्सन' (एफएफ/मैक)। मैं फ़ायरबग कंसोल का उपयोग कर कमरे में एक आइटम जोड़ सकता हूं, बिना किसी त्रुटि के।
समस्या को पुन: उत्पन्न करने के लिए, 'jspec init test' का उपयोग करके एक टेम्पलेट जेएसपीसी प्रोजेक्ट बनाएं। फिर तो जैसे निम्नलिखित फ़ाइलों को संपादित:
yourlib.core.js
var Game = {};
Game.item = function() {
var result = {
name : 'Undefined',
room : null
}
return result;
};
Game.room = function() {
var result = {
items : [],
addItem : function (name) {
var item = Game.item();
item.name = name;
item.room = this;
this.items.push(item);
return item;
}
};
return result;
};
spec.core.js
describe 'Room'
before_each
room = Game.room()
end
describe 'addItem()'
before_each
potion = room.addItem('Potion')
key = room.addItem('Key')
end
//this is fine
it 'should return two different items'
key.should_not.be potion
end
//InternalError: too much recursion
it 'should not give recursion error'
key.should.be potion
end
end
end
JSpec के पहले कभी नहीं सुना। क्षमा करें :(। लगभग सभी आपका कोड इतना आसान लगता है कि कुछ भी पागल न हो, शायद "item.room = this;" – Tei