github.com/igggame/nebulas-go@v2.1.0+incompatible/nf/nvm/v8/test/test_inctruction_counter.js (about) 1 // Copyright (C) 2017 go-nebulas authors 2 // 3 // This file is part of the go-nebulas library. 4 // 5 // the go-nebulas library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // the go-nebulas library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with the go-nebulas library. If not, see <http://www.gnu.org/licenses/>. 17 // 18 19 _instruction_counter.incr(1); 20 console.log('count = ' + _instruction_counter.count); 21 if (_instruction_counter.count != 1) throw new Error('_instruction_counter.count error, expected ' + 1 + ', actual is ' + _instruction_counter.count); 22 23 _instruction_counter.incr(2); 24 console.log('count = ' + _instruction_counter.count); 25 if (_instruction_counter.count != 3) throw new Error('_instruction_counter.count error, expected ' + 3 + ', actual is ' + _instruction_counter.count); 26 27 _instruction_counter.incr(3); 28 console.log('count = ' + _instruction_counter.count); 29 if (_instruction_counter.count != 6) throw new Error('_instruction_counter.count error, expected ' + 6 + ', actual is ' + _instruction_counter.count); 30 31 32 _instruction_counter.count = 0123; 33 if (_instruction_counter.count != 6) throw new Error('_instruction_counter.count error, expected ' + 6 + ', actual is ' + _instruction_counter.count); 34 35 _instruction_counter.incr(4); 36 console.log('count = ' + _instruction_counter.count); 37 if (_instruction_counter.count != 10) throw new Error('_instruction_counter.count error, expected ' + 10 + ', actual is ' + _instruction_counter.count); 38 39 delete _instruction_counter.count; 40 if (_instruction_counter.count != 10) throw new Error('_instruction_counter.count error, expected ' + 10 + ', actual is ' + _instruction_counter.count); 41 42 _instruction_counter.incr(5); 43 console.log('count = ' + _instruction_counter.count); 44 if (_instruction_counter.count != 15) throw new Error('_instruction_counter.count error, expected ' + 15 + ', actual is ' + _instruction_counter.count); 45 46 _instruction_counter.incr(-1); 47 console.log('count = ' + _instruction_counter.count); 48 if (_instruction_counter.count != 15) throw new Error('_instruction_counter.count error, expected ' + 15 + ', actual is ' + _instruction_counter.count);