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

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


90547
    args[0]->IsArrayBuffer() || args[0]->IsSharedArrayBuffer());
53
13101
}
54
55
1662
static void IsBoxedPrimitive(const FunctionCallbackInfo<Value>& args) {
56
  args.GetReturnValue().Set(
57

9778
    args[0]->IsNumberObject() ||
58

7644
    args[0]->IsStringObject() ||
59

7190
    args[0]->IsBooleanObject() ||
60

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