GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/node_types.cc Lines: 18 18 100.0 %
Date: 2019-01-07 12:15:22 Branches: 26 28 92.9 %

Line Branch Exec Source
1
#include "node_internals.h"
2
3
using v8::Context;
4
using v8::FunctionCallbackInfo;
5
using v8::Local;
6
using v8::Object;
7
using v8::Value;
8
9
namespace node {
10
namespace {
11
12
#define VALUE_METHOD_MAP(V)                                                   \
13
  V(External)                                                                 \
14
  V(Date)                                                                     \
15
  V(ArgumentsObject)                                                          \
16
  V(BigIntObject)                                                             \
17
  V(BooleanObject)                                                            \
18
  V(NumberObject)                                                             \
19
  V(StringObject)                                                             \
20
  V(SymbolObject)                                                             \
21
  V(NativeError)                                                              \
22
  V(RegExp)                                                                   \
23
  V(AsyncFunction)                                                            \
24
  V(GeneratorFunction)                                                        \
25
  V(GeneratorObject)                                                          \
26
  V(Promise)                                                                  \
27
  V(Map)                                                                      \
28
  V(Set)                                                                      \
29
  V(MapIterator)                                                              \
30
  V(SetIterator)                                                              \
31
  V(WeakMap)                                                                  \
32
  V(WeakSet)                                                                  \
33
  V(ArrayBuffer)                                                              \
34
  V(DataView)                                                                 \
35
  V(SharedArrayBuffer)                                                        \
36
  V(Proxy)                                                                    \
37
  V(WebAssemblyCompiledModule)                                                \
38
  V(ModuleNamespaceObject)                                                    \
39
40
41
#define V(type) \
42
  static void Is##type(const FunctionCallbackInfo<Value>& args) {             \
43
    args.GetReturnValue().Set(args[0]->Is##type());                           \
44
  }
45
46
1974755
  VALUE_METHOD_MAP(V)
47
#undef V
48
49
7783
static void IsAnyArrayBuffer(const FunctionCallbackInfo<Value>& args) {
50
  args.GetReturnValue().Set(
51


53295
    args[0]->IsArrayBuffer() || args[0]->IsSharedArrayBuffer());
52
7783
}
53
54
1554
static void IsBoxedPrimitive(const FunctionCallbackInfo<Value>& args) {
55
  args.GetReturnValue().Set(
56

9178
    args[0]->IsNumberObject() ||
57

7234
    args[0]->IsStringObject() ||
58

6856
    args[0]->IsBooleanObject() ||
59

11286
    args[0]->IsBigIntObject() ||
60
7148
    args[0]->IsSymbolObject());
61
1554
}
62
63
3661
void InitializeTypes(Local<Object> target,
64
                     Local<Value> unused,
65
                     Local<Context> context,
66
                     void* priv) {
67
3661
  Environment* env = Environment::GetCurrent(context);
68
69
#define V(type) env->SetMethodNoSideEffect(target,     \
70
                                           "is" #type, \
71
                                           Is##type);
72
3661
  VALUE_METHOD_MAP(V)
73
#undef V
74
75
3661
  env->SetMethodNoSideEffect(target, "isAnyArrayBuffer", IsAnyArrayBuffer);
76
3661
  env->SetMethodNoSideEffect(target, "isBoxedPrimitive", IsBoxedPrimitive);
77
3661
}
78
79
}  // anonymous namespace
80
}  // namespace node
81
82
3596
NODE_MODULE_CONTEXT_AWARE_INTERNAL(types, node::InitializeTypes)