Update Iot.js
[platform/upstream/iotjs.git] / test / run_pass / test_fs_stat.js
1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16
17 var fs = require('fs');
18 var assert = require('assert');
19
20
21 var stats1 = fs.statSync('test_fs_stat.js');
22 assert.equal(stats1.isFile(), true);
23 assert.equal(stats1.isDirectory(), false);
24
25 fs.stat('test_fs_stat.js', function(err, stats) {
26   if (!err) {
27     assert.equal(stats.isFile(), true);
28     assert.equal(stats.isDirectory(), false);
29   }
30   else {
31     throw err;
32   }
33 });
34
35
36 var stats2 = fs.statSync('../resources');
37 assert.equal(stats2.isDirectory(), true);
38 assert.equal(stats2.isFile(), false);
39
40 fs.stat('../resources', function(err, stats) {
41   if (!err) {
42     assert.equal(stats.isDirectory(), true);
43     assert.equal(stats.isFile(), false);
44   }
45   else {
46     throw err
47   }
48 });