fn constants(vm: &mut VM, self_val: Value, args: &Args2) -> VMResult {
    args.check_args_range(0, 1)?;
    let inherit = if args.len() == 0 {
        true
    } else {
        vm[0].to_bool()
    };
    let mut v: Vec<Value> = vec![];
    let mut class = self_val.into_module();
    let object = vm.globals.classes.object;
    loop {
        class
            .const_table()
            .keys()
            .filter(|x| x.is_constant())
            .map(|k| Value::symbol(*k))
            .for_each(|e| v.push(e));
        if !inherit {
            break;
        }
        match class.upper() {
            Some(superclass) => {
                if superclass.id() == object.id() {
                    break;
                } else {
                    class = superclass;
                };
            }
            None => break,
        }
    }
    Ok(Value::array_from(v))
}
## instance method Module#constants
- constants(inherit = true) -> [[Symbol]]

https://docs.ruby-lang.org/ja/latest/method/Module/i/constants.html
ruruby/src/builtin/module.rs