github.com/igggame/nebulas-go@v2.1.0+incompatible/nf/nvm/test/test_require.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  'use strict';
    19  
    20  var console2 = require('console.js');
    21  if (!Object.is(console, console2)) {
    22      throw new Error("require should caches libs.");
    23  }
    24  
    25  var err = new Error("require should throw error when file does not exist.");
    26  try {
    27      require("./not-exist-file");
    28      throw err;
    29  } catch (e) {
    30      if (e === err) {
    31          throw e;
    32      }
    33  }
    34  
    35  /* // disable this file, which can't be stored in windows system.
    36  err = new Error("require should throw error while file name contains \".");
    37  try {
    38      require("./require_file_\"1.js");
    39      throw err;
    40  } catch (e) {
    41      if (e === err) {
    42          throw e;
    43      }
    44  }
    45  */